Reading BarCode image using Aspose.BarCode Cloud API in SalesForce throws error

Hello,

I am experimenting with the Barcode Cloud API but I can not get it to work.

This is my salesforce code to call your API :

@RemoteAction

public static String Aspose_ProcessCommand(String strURI, String strHttpCommand, String strContent, String ContentType) {

try {

HttpRequest request = new HttpRequest();

Integer len = 0;

if (strContent != null) {

request.setBody(strContent);

len = strContent.length();

}

request.setEndpoint(strURI);

request.setMethod(strHttpCommand);

if (ContentType.toLowerCase() == ‘xml’)

request.setHeader(‘Content-Type’, ‘application/xml’);

else

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

request.setHeader(‘Content-Length’, String.valueOf(len));

request.setHeader(‘Accept’, ‘application/json’);

[//request.setTimeout](https://request.settimeout/)(Timeout);

Http http = new Http();

HttpResponse res = http.send(request);

return res.getBody();

} catch (Exception ex) {

system.debug(ex.getStackTraceString());

return null;

}

}

and here is the link that is being called : https://api.aspose.com/v1.1/barcode/recognize?type=Code128&url=http://baytechlabel.com/files/originals/Code128.jpg&appSID=SECRET_APP_SIDa&signature=GENERATE_SIGNATURE

Obvously SECRET_APP_SID and GENERATE_SIGNATURE have a real value.

The response from the call is “null”. I need this for a POC for a client. How can I get it to work ? And how fast ?

Thank you.

Hi,

Thank you for contacting Aspose support, and welcome to Aspose.BarCode support forum.

It seems that your request URL is not correct, as you are missing a “Z” in the resource “recognize”. Please correct the URL as below, and give it a try again.

https://api.aspose.com/v1.1/barcode/recognize?type=Code128&url=http://baytechlabel.com/files/originals/Code128.jpg

Moreover, please note that the HttpRequest method would be “POST” in this case.

Please feel free to write back in case you face any difficulty.

Hello,


Thank you for your reply.

1. The “z” is present in the link, but for some reason it is not visible in the first post. So the link seems ok.

2. What do you mean about the POST ? Do I need to change something to make it to work ?

3. How do I get it to work ?

Best regards,

Hi,


We have tested the request URL (as specified in our previous post) in different environments, and it is returning correct results. We would like to review your complete code therefore we request you to please provide a sample application as we need to see what parameters are you passing to the method outlined in your original post. By reviewing your code, we will be in a better position to suggest how you should proceed further to avoid the said problem.

The parameter “strHttpCommand” from your code should be “POST” in order to use the “recognize” resource in this scenario.

Hi again,


Adding more to my previous response, we already have working samples specially built for APEX / Force.com developers to work with Apose REST API. These samples are hosted on Github, and also include demonstrations of Aspose.BarCode for Cloud.

Please feel free to write back in case you face any difficulty.

Hello,

Thank you. The GitHub example helped. It is now working, but I have another problem.

My image is in a salesforce document. It is accessable via this link :

https://c.na17.content.force.com/servlet/servlet.ImageServer?id=015o00000001p27AAA&oid=00Do0000000K3juEAC

Even though I can open the image in my browser, even as a non logged in user, it does not seem to be a ok parameter for the aspose barcode decoder.

I get this response : {“Message”:“Parameter is not valid.”}

Please help. My Demo is tomorrow.

Best regards,

I did not solve the issue above, but I am saving the camera capture to a ftp server and sending that link to Aspose. This works, but the Barcode that is returned is wrong.

What can I do ?

This is the code I get back from Aspose : T0E6R0e

The image that is being sent is : http://www.esentiali.com/cloudware/images/1406153831338.png


I found various workarounds, and now all seems to work.
Because the demo is tomorrow, I am worried about the limit on the trial version. Is there a way to reset the trial counter or bump the limit up ?

Thank you in advance.

Best regards,

Hi,


First of all, please accept my apology for the delayed response.

It’s good to know that you are up and running again. Regarding the API limits in the trial version, I am afraid you may not be able to increase the number of calls. However, I am in discussion with the concerned department to find a solution for this scenario. I will shortly get back to you with updates in this regard.

How many hours left till your demo?

Hi again,


Good news, we can reset the limit on your Aspose for Cloud account. Please provide the email address attached to the Aspose for Cloud account so we may proceed with resetting the limits.

Sorry for a late reply, but we are in different time zones I suppose :slight_smile:


Great news regarding the reset of the counter. I believe my demo has been moved to tomorrow or monday. I will find out soon and let you know. In the mean while, I will demo internally the idea to the people responsible for the POC, and then will ask for a reset. I hope it is ok like this.

Thank you for all the help. Be in touch soon.

Hello,

Did you get a chance to check the error regarding the following link :

https://c.na17.content.force.com/servlet/servlet.ImageServer?id=015o00000001p27AAA&oid=00Do0000000K3juEAC

For more info see the post above (a few posts above)

Hi,


Yes, I have checked your provided URL. The image is inline as a part of the HTTP response encoded in base64 data format. Unfortunately, the recognize resource needs an Image File for processing, whereas image file can be present on cloud storage, local disk or on remote location. I am looking into this further to find a workaround for this situation.

Hi

dotSnipe:
Did you get a chance to check the error regarding the following link :

https://c.na17.content.force.com/servlet/servlet.ImageServer?id=015o00000001p27AAA&oid=00Do0000000K3juEAC

For more info see the post above (a few posts above)
Well, you need to pass the url parameter with single quote:
http://api.aspose.com/v1.1/barcode/recognize?type=Code128&url='https://c.na17.content.force.com/servlet/servlet.ImageServer?id=015o00000001p27AAA&oid=00Do0000000K3juEAC'

There will be no error, but our cloud service is not recognizing it. We can recognize Code128 barcode as “T0E6G00 using the latest code base. Anyway, we have logged a task to integrate the latest code base. This task has been logged under ticket id SAASBARCODE-46 in our issue tracking system. We’ll keep you informed regarding any available updates. We’re sorry for the inconvenience you faced.

Thank you for the update.