Getting error 200 Ok in the below code

2017-11-19 04:06:43

Hi i am trying to integrate the 3rd party resume parser in salesforce i have written the below code. Please let me know what i am doing wrong.

Http http = new Http();

HttpRequest request = new HttpRequest();

request.setEndpoint('http://example.com');

List doc = [select body,name from attachment where Id='xxxxxxx'];

attachment doc1=doc[0];

String File= doc1.name;

Blob bodyblob = doc1.Body;

String bodystr=EncodingUtil.base64Encode(bodyblob);

String Userkey='xxxxxxxxx';

String Version='xxx';

String subU='xxxxxxxxxx';

request.setMethod('POST');

request.setHeader('Content-Type', 'application/json');

request.setbody('{"filedata":'+bodystr+',"filename":'+File+',Userkey="xxxxxx","version":"xxx","subuserid":"xxxxxxxx"}');

HttpResponse response = http.send(request);

if (response.getStatusCode() != 201) {

System.debug('The status code returned was not expected: ' +

response.getStatusCode() + ' ' + response.getStatus());

System.debug(response.getB

  • 200 is a good status, not an error status. That said, it looks like Userkey should be userkey (note the capital U is incorrect). Always make sure you're paying attention to capitalization when working with APIs.

    2017-11-19 04:18:46