1

I'm trying to sending a field value to third part but here the issue is

Suppose the filed is Name = "Test Account" here in this case call will be failed but for suppose

Field Name is like Name = "TestAccount" in this case call is giving response as success

Could anyone suggest how to avoid this issue

Request :

HttpResponse[Status=BAD_REQUEST, StatusCode=400]

System.HttpRequest[Endpoint=https://adobeconnect.com/api/xml?action=event-register&sco-id=1629956237&login=koti4@gmail.com&password=test1234&password-verify=test1234&first-name=Srinu&last-name=s&Company=Test Company&session=apac1breezci34y2pfd23eyiaq, Method=POST]

Success response :

System.HttpRequest[Endpoint=https://adobeconnect.com/api/xml?action=event-register&sco-id=1629956237&login=koti5@gmail.com&password=test1234&password-verify=test1234&first-name=Srinu&last-name=s&Company=TestCompany&session=apac1breezci34y2pfd23eyiaq, Method=POST] 09:50:38.13 (956337528)|CALLOUT_RESPONSE|[54]|System.HttpResponse[Status=null, StatusCode=200]

Thanks, Raghu

  • Please edit this question to include specific code and details of the target of the request. If you are calling out to a non-Salesforce third party system, we may not be able to help you. – David Reed Aug 8 at 14:04
  • please check the request I have added and see the company name field in two requests – Raghu Aug 8 at 14:16
3

If the data are being passed as URL parameters rather than in the body of the HTTP request, you need to encode the request URL to ensure there are no spaces. Without seeing your code for how the request is being built, it's not possible to give exact guidance, but either EncodingUtil.urlEncode() or String.replace(' ','+') if you only have spaces, should work.

5

You need to URL-Encode the parameters. A space in the actual URL will cause an error (as well as many other non-alphanumeric characters). Use PageReference to build a proper URL:

PageReference ref = new PageReference('https://adobeconnect.com/api/xml');
ref.getParameters().put('action','event-register');
// ... //
ref.getParameters().put('Company','Test Account');
req.setEndpoint(ref.getUrl()); // Properly encoded URL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.