Test API


This page will provide you instructions on how to test our API, Extend Commerce API, directly and examples on how to communicate with our API.

Test API

If you want to test Extend Commerce API, 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 Commerce API's with other methods than "Get", please contact your client manager at Extend Commerce or the Extend Commerce Support to get the correct testing credentials.

Extend Commerce 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 Commerce 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 Commerce API.

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. Extend Commerce API.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"));
            
            string credentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(username + ":" + password));
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("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();
        }
    }
}