function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
UADUAD 

Post request

Hello there,

 

I need to set an http request with the setMethod('POST'); i already did a few http request with the GET method and it was working pretty well, but my POST request doesn't work.

 

I was thinking that i just need to change the setMethod parameter, after a few research i saw a way to put the parameters

using setBody but isn't working. I got error from my server as "Invalid parameters"

 

Here some code sample:

 

    	Http http = new Http();
        HttpRequest req = new HttpRequest(); 
        HttpResponse res = new HttpResponse();
        req.setMethod('POST');
        req.setEndpoint('http://www.usineadesign.com/api/order?input=');

 

And i tried to pust the parameters following this way:

 

req.setBody(EncodingUtil.urlEncode(string.valueof(line.Id_uad__c), 'UTF-8')+'|'+ EncodingUtil.urlEncode(string.valueof(line.Quantity.setscale(0)), 'UTF-8')
				+ '|' +EncodingUtil.urlEncode(string.valueof(line.Quantity.setscale(0)), 'UTF-8') + EncodingUtil.urlEncode(line.MPN__c , 'UTF-8') + '|' +
				EncodingUtil.urlEncode(string.valueof(line.UnitPrice) , 'UTF-8'));

 

Does anyone can help me?

Thanks