• jeevan dhruvsoft
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 1
    Replies

I must make a http request to Shopify in Salesforce. I used following url format as endpoint url for setEndpoint method

HttpRequest req= new HttpRequest(); 
req.setEndpoint('https://apikey:password@hostname/admin/resource.xml'); 
req.setMethod('GET'); 

I get following log:

CALLOUT_RESPONSE|[18]|System.HttpResponse[Status=Unauthorized, StatusCode=401]

And I get return value from body of HttpResponse:

<?xml version="1.0" encoding="UTF-8"?> <hash> <errors>[API] Invalid API key or access token (unrecognized login or wrong password)</errors> </hash>

Also I have tried to following structure but I haven't been succesful.

Blob headerValue = Blob.valueOf(apikey+ ':' + password);
String authorizationHeader = 'BASIC ' +
EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);

And also following url works properly in any browser

apikey:password@hostname/admin/resource.xml

What should I do for HttpResponse status code be 200.

I must make a http request to Shopify in Salesforce. I used following url format as endpoint url for setEndpoint method

HttpRequest req= new HttpRequest(); 
req.setEndpoint('https://apikey:password@hostname/admin/resource.xml'); 
req.setMethod('GET'); 

I get following log:

CALLOUT_RESPONSE|[18]|System.HttpResponse[Status=Unauthorized, StatusCode=401]

And I get return value from body of HttpResponse:

<?xml version="1.0" encoding="UTF-8"?> <hash> <errors>[API] Invalid API key or access token (unrecognized login or wrong password)</errors> </hash>

Also I have tried to following structure but I haven't been succesful.

Blob headerValue = Blob.valueOf(apikey+ ':' + password);
String authorizationHeader = 'BASIC ' +
EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);

And also following url works properly in any browser

apikey:password@hostname/admin/resource.xml

What should I do for HttpResponse status code be 200.