Page tree
Skip to end of metadata
Go to start of metadata

This page will provide you instructions on how to test our API's directly and examples on how to communicate with our API's.

Test API

If you want to test Extends API's you may use the below Test credentials (Read only). These credentials will allow you to test the "Get" methods in the Extend API Library, meaning you will be able to read data but not create.

 Test credentials (Read only)

Username: APIReadOnly

Password: APIReadOnly

Client parameter for testing: APIDEMO

If you want to test any of the Extend API's with other methods than "Get", please contact your client manager at Extend or the Extend Support to get the correct testing credentials.

Extend use different credentials depending on which method you want to test, so we request that you specify which methods you are interested in.

When you have your testing credentials you may test the different methods in the API interface in the Extend API Library or by making your own API calls.

Fill out the required parameter values, and the optional parameters if they are applicable, and execute by clicking the "Try it out" button. You will be prompted to fill in your credentials to proceed.

 "Try it out" - description

Extend recommend you to not use the Microsoft Edge browser, since the login-prompt is not fully supported.

Your API response will be showed below the "Try it out" button.

Example Code

Here are some example code on how to communicate with the Extend API's.

It´s a c# example, click "c# example" below to view the example. If you want to download the example as a project, click here to download. ExtendAPI.zip

 c# example
using System.Net.Http.Headers;

namespace ExtendAPI
{
    class Program
    {
        static void Main(string[] args)
        {
            string username = "APIReadOnly";
            string password = "APIReadOnly";
            string yourClient = "APIDemo";
            string apiurl = "https://developer.lxir.se/RESTAPI/v1_0/{client}/Products";

            apiurl = apiurl.Replace("{client}", yourClient);
                               
            HttpClient client = new HttpClient();           
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            //Add custom header for Extend authorization
            //Note! Add the authorization to header "ExtendBasicAuthorization". When using developer.lxir.se normal basic auth will work, but in production ExtendBasicAuthorization must be used.
            string credentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(username + ":" + password));
            client.DefaultRequestHeaders.Add("ExtendBasicAuthorization", "Basic " + credentials);
            
            HttpResponseMessage response = client.GetAsync(apiurl).Result;
            HttpContent content = response.Content;

            // Check Status Code                                
            Console.WriteLine("Response StatusCode: " + (int)response.StatusCode);

            // Read the string.
            string result = content.ReadAsStringAsync().Result;

            // Display the result.
            if (result != null)
            {
                Console.WriteLine(result);
            }
            
            Console.ReadKey();
        }
    }
}

Difference between Extend API's in lab and prod.

In lab (developer.lxir.se) you use Basic authentication to identify who's doing the API call. Log-in credentials is submitted, according to standard, in a header field: Authorization.

In production Extend uses a API gateway, which entails a different type of Basic authentication. The difference from usual Basic authentication is that the log-in credentials i submitted in another field in the call, ExtendBasicAuthorization. The lab environment supports both options.

For usage of production API's, there are these differences:

  • The HTTP header field ExtendBasicAuthorization must be used when submitting log-in credentials.
  • In production the API URL is case sensitive, which may result in the error message"Missing Authentication Token"



 

 

  • No labels