Identifying yourself during data exchange

Identification is performed by means of an HTTP header.

The used method is HTTP Basic Authentication.

In each HTTP request, the header must contain the information allowing the Marketplace to authenticate itself when connecting to Marketplace Web Services.

Description of HTTP headers:

Headers Description Values to use
Accept Determines the format of the contents that will be returned by the server.

REST architecture that allows to perform data exchange in JSON format

'Accept: application/json'
Authorization: Description Identification token according to the "Basic Authentication over HTTPS" principle. Consists of an identifier and a password of the API user separated by a ':', both encoded in Base64. 'Authorization: Basic YWRtaW46YWRtaW4='
Content-type Determines the format of the contents sent to the server. 'content-type: application/json'
Method

See the table in the Web Service resources chapter to see the methods to use according to each resource.

GET | POST | PUT | DELETE

The steps for building headers are:

  1. Use the Basic Authentication method.
  2. Specify the used method in the Authorization header: Basic followed by the login and the password (encoded in Base64) separated by a ':'.
  3. Encode the obtained result in Base64.
  4. Add the chain into "Basic".
    Note:
    Do not forget to add a space after Basic.

  • Example cURL:
    $ curl 'https://secure.lyra.com/marketplace-test/123456/orders/' -H
    'Authorization: Basic YWRtaW46YWRtaW4=' -H
    'Content-Type: application/json' -H 'Accept: application/json' --data
    '{}'
    -i
  • Example of a complete request in Python:
    r = requests.post(
    <target url>,
    data=<json data>,
    auth=(<api login>, <api password>),
    headers={'content-type': 'application/json'},
    verify=False
    )
  • Example of a request in .NET:
    var myURL = "https://secure.lyra.com/marketplace-test/orders?expand=items"
    HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(myURL);
    myHttpWebRequest.ContentType = "application/json";
    myHttpWebRequest.Accept = "application/json";
    myHttpWebRequest.Method = "post";
    string authInfo = userName + ":" + userPassword; 
    authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
    myHttpWebRequest.Headers["Authorization"] = "Basic " + authInfo;