[ardoHTTP] HTTPPost Data

[ardoHTTP] HTTPPost Data

Forge Component
Published on 2015-06-04 by Ricardo Silva
15 votes
Published on 2015-06-04 by Ricardo Silva
Hi Ricardo,

Thanks for your components. I am using ardoJSON in one of my projects.

Now I needed to use ardoHTTP. I have to post some data to a server which accepts only JSON input. It also requires HTTP Basic Authentication.

I have tested my data using Google Chrome Extension "Advance REST Client Application". But when using ardoHTTP's HTTPPost method, the server returns error "Input string was not in a correct format."

Authentication seems to be working. I am using ardoJSON's OutSystems2JSON action to convert an object to JSON which seems to working fine.

I have tried with/without header 'NoAutoCompression', with/without setting Content Type as input parameter. All combinations of Content Type i.e. 'application/json', 'application/json;' and 'application/json; charset=UTF-8' has been tried.

I am using .NET stack.

Can you help?
With that particular error I'd look at the URL you are building instead. It may be creating a wrongly constructed URL.

Without more information than this I'm afraid I can't venture much of a guess as to what may be going wrong. Can you provide an eSpace that reproduces this issue? If you prefer, you can provided it to me via private message.
Thanks for your prompt reply.

I can share an espace with you, but the server I am talking to has some constraints. It is a payment processing server and accepts requests only from within USA. Also, I will have to share my test account's secret key.

But as far as url is concerned, I am not building it. It is a static value i.e. "https://api.chargeio.com/v1/charges"

Plz let me know if you have any other thoughts. Could it be something with the content length value that you are passing as header. I was looking at java code in your extension.
Why are you looking at the Java implementation if you're using the .NET version ?

Content-Length of the POST request is automatically filled in by the .NET framework, so this value will be as much as it takes to utf-8 encode the string.

The only thing I can think of is that the request is somehow malformed, meaning that there is something wrong with the format of the JSON that you are passing to the request. You can debug the issue and catch the JSON string being used and test it using another tool. If you are still having problems figuring out, perhaps you can contact the service provider's support in order to better understand why their service is throwing that error.

If you are using version 9 of the OutSystems Platform, perhaps an alternative would be to leverage the REST API consumption capabilities of the OutSystems Platform instead of using this component. This way you can have access to the network traces of the requests and look more deeply into the matter.
Thanks for your reply and pointers.

My project uses .NET stack but I myself am a java dev. Hence, just to understand what headers you are manipulating, I was looking at Java code.

As mentioned earlier, I have successfully used Advance REST Client Application and have looked into JSON which is correctly formatted.

I will look into REST API and will also try if I can get an answer from the service provider.

Thanks again for your help.

A colleague of mine debugged the code which I had written using ardoHTTP and found out another issue in my logic. Your code was working correctly.

Sorry for the inconvenience and thanks for your support.