Salesforce

Using HTTP Functions with an At Sign Character in the User Name or Password (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

Using HTTP Functions with an At Sign Character in the User Name or Password (Magic xpa 3.x)

Objective

This Technical Note explains how to use HTTP functions with basic authentication when there is a @ character in the user name or password

Description

When using HTTP functions, such as HTTPCall, HTTPPost and HTTPGet, if the service URL requires a user name and password, the URL should be HTTP://User:Password@URL.

This works as long as the user name or password do not have the at sign (@) character in them. If the user name or password contains the @ character, the HTTP call fails.

Solution

The call fails because the engine parses the URL after the @ character before making the HTTP call. The engine does not "know" the exact service URL, if the user name or password also has the @ character.

The solution is as follows:

  1. Ask the service URL to create a user account that does not have the @ character.

  2. Add the Authorization: Basic token as the Header parameter in the HTTP call.

To get the Authorization: Basic token, you need to trace the request using a network tool, such as Fiddler2 or Wireshark. For this, you need to make the dummy HTTP request from a browser using the HTTP://User:Password@URL syntax and then trace the request with the network tool.

You will be able to see the request headers, such as: Authorization: Basic XXXXXXXXXXXXXXXXXX where XXXXXXXXXXXXXXXXXX will be a base64 encrypted string for the user name and password.

You can copy and paste the header value "as is" and use it in HTTP call functions.

For example:

HTTPPost('http://myserviceurl',mybody,'Authorization: Basic dFK0LWVvbC50ZXN0OlBAc3N3MHJk',Header2,Header3....)

HTTPCall('Post','http://myserviceurl',mybody,'Authorization: Basic dFK0LWVvbC50ZXN0OlBAc3N3MHJk',Header2,Header3....)

Reference
Attachment 
Attachment