Skip to main content
Dev TNOPPV5 님이 #Apex에 질문했습니다
Hello,

I am calling one rest api in salesforce. Following is the deatil code:

 HttpRequest req = new HttpRequest();

                req.setEndpoint('https://example.com'+lo[0].Company__c);

                req.setMethod('GET');

                req.setHeader('ACCEPT','application/xml');

                req.setHeader('Authorization', authorizationHeader);

                Http http = new Http();

                HTTPResponse res = http.send(req);

                system.debug('res:'+res);

In above code lo[0].Comapny__c value is " Test Example " . In this name there is space between Test and Example. When My code execute for this example it is given me blank response body.

I am passing like "TestExample" it is working. Actually when space came at that time "%20" should pass in that url. 

I know how to do in .net , PHP, JAva ( line encodeURI("Test Example)"). 

How can i do this in Salesforce? Please help me.
답변 11개
  1. 2016년 6월 22일 오전 7:26
    Hello Suraj,

    I tried that but when is do like this:

     

    EncodingUtil.urlEncode('Test Example', 'UTF-8')

    result comes like "Test+Example"

    Result I am expecting like: "Test%20Example"
0/9000