Hi Guys, Good day! Please help I'm having problem with our REST API what I'm trying to do is upload an image to an image upload field type. Here is the code...
'username', 'password'=>'password'));
$extractSessId = new SimpleXMLElement($obtainSessionId);
$actualSessId = $extractSessId->sessionId;
$uploadImage = getAppxysXml('https://www.
What do you see in rest.log file when you use setBinaryData REST API?
Here is the logs, seems to be no registration of API calls.
[2012-11-06 20:28:46,336] Unloaded from REST Server at 11/06/2012 08:28 PM
[2012-11-07 09:44:29,169] Loaded on REST Server at 11/07/2012 09:44 AM
[2012-11-07 09:44:29,200] User Villafuerte successfully logged in: sessionId=rest-8165350031435663619
[2012-11-07 09:59:08,900] Unloaded from REST Server at 11/07/2012 09:59 AM
[2012-11-07 10:53:18,520] Loaded on REST Server at 11/07/2012 10:53 AM
[2012-11-07 10:53:18,551] User Gutierrez successfully logged in: sessionId=rest-2416108970043884817
[2012-11-07 11:00:45,647] Unloaded from REST Server at 11/07/2012 11:00 AM
[2012-11-07 11:09:50,134] Loaded on REST Server at 11/07/2012 11:09 AM
[2012-11-07 11:09:50,165] User Gutierrez successfully logged in: sessionId=rest6631096849633827009
[2012-11-07 11:10:27,559] Unloaded from REST Server at 11/07/2012 11:10 AM
[2012-11-07 11:22:31,648] Loaded on REST Server at 11/07/2012 11:22 AM
[2012-11-07 11:22:31,679] User Gutierrez successfull
I don't see log from setDataField API call in your posting.
I used the following Java code for testing:
Map params = new HashMap();
params.put("sessionId", sessionId);
params.put("id", "832878");
params.put("fieldName", " template_file");
params.put("fileName", "fw9.pdf");
params.put("contentType", IContentTypes.MIME_PDF);
byte[] b = FileUtil.readFile(new File("c:/temp/fw9.pdf"));
System.out.println("bytes: "+b.length);
params.put("value", Base64Encoder.encode(b));
String res = HTTPClient.sendRequest("POST", baseURL+"setBinaryData", params);
System.out.println("setBinaryData: "+res);
Got this response:
Field "Template File" has been updated on TEST
and this log:
[2012-11-07 20:23:20,531] User Pavel Vorobiev successfully logged in: sessionId=rest-5766857947568172584
[2012-11-07 20:23:20,609] setDataField id=832878
It's working now.
For anyone who's having a trouble here is the code...
function getAppxysXml($url, $post_data){
$crl = curl_init();
curl_setopt ($crl, CURLOPT_POST, true);
curl_setopt ($crl, CURLOPT_POSTFIELDS, $post_data);
curl_setopt ($crl, CURLOPT_HEADER, false);
curl_setopt ($crl, CURLOPT_URL, $url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_SSL_VERIFYPEER, false);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
$imageToBinary = file_get_contents('uploads/original/1499132.jpg');
$basesixfour = urlencode(chunk_split(base64_encode($imageToBinary)));
$login = getAppxysXml('https://www.domain.com/rest/api/login', array('loginName'=>'your_username', 'password'=>'your_password'));
$parseAsXmlDoc = new SimpleXMLElement($login);
$obtsessionId = $parseAsXmlDoc->sessionId;
$saveIt = getAppxysXml('https://www.domain.com/rest/api/setBinaryData?sessionId='.$obtsessionId.'&id=1499132&fieldName=photo&contentType=image/jpeg&fil
I'm having the same problem, I'm using javascript and AJAX. Is there any example for setBinarData using ajax?
We don't have examples of using REST API through AJAX.
Thank you for the response. Is there anyway that you can help me?
Hi Ronald, we don't offer development services today. You may want to contact one of our development partners such as Rollbase Philippines for help. Feel free to email us directly if you'd like us to connect you with them: support@rollbase.com
Regards,
Matt
Thanks Matt for the response.
Okay, aside from JAVA have you tested this API using different language such as C or C# or even using AJAX. The easiest way to implement REST API is via AJAX, is this functionality is supported by AJAX? I just need to know if this API works using that language.