How To Use Mockbin & JSON Parser In Conjunction With Push APIs

How To Use Mockbin & JSON Parser In Conjunction With Push APIs

What Has Been Updated Within Push APIs?

The following article is going to run through how push APIs can be used in conjunction with integrations to view external links to better manage customer orders to capture and see order formats. The following is all public facing so anyone within companies working with Kornit X can use this option.
Overall this is an excellent method for testing orders and ensuring our customer can work with their developers to implement this feature. 

What Can Mockbin Be Used For?

Mockbin can be accessed by going to the following URL - https://mockbin.org/
Mockbin was developed to allow customers to generate custom endpoints to test, mock and track HTTP requests and responses between APIs. Mockbin is a feature that can be used in conjunction with any supplier integration within platform that generates URL Endpoints. Examples of this include the  Generic API Supplier Integration and the order export API. With customers who use API  end points which come out of platform this allows you to capture and see the format that they look like.  The main ability here is that by setting this up It will allow you  to see exactly what you will get with your orders. 

Can You Show Me How To Set Mockbin Up?

To be able to set this up you need to head to the Mockbin site, and within this site you need to select the "Create Bin" option shown in the green button. We have shown this in the screenshot below. 

Once you select the "Create Bin" option you will be redirected to a second page but you can disregard any of the options like "Bin Builder", you just need to press the second "Create Bin" option as shown below.

When you select the "Create Bin" option you will be redirected to an API end point that is contently listening. What this means is the URL will always pick up orders that we send through linking to this as a "Push URL". You need to take out the top URL minus the "/view" field of the URl. If you copy this out please save it to one side and head to the platform. 

Once you have the URL and head to platform you need to open up your company and enable the supplier integration, within this example we are setting a "Generic API" supplier integration as shown below. 
Please note this will ONLY work with our integrations that offer a "Push URL" option.

Once you select the "Generic API" option you will see the option for "Push URL", now with your URL saved from mockbin you just need to copy this link into the field like the example shown below. 
Options such as Auth Username,  Auth Password, Data Strategy etc are options the customer can enable if they require them.

Now when you add this "Push URL" simply save the option and reload your mockbin. You can see in my example th start timestamp was set and a good way to test this is to get an order in for that company. 
A quick method to test could be to duplicate a test order, you simply just need the order to get to the status of received by supplier, this will mean the order will be ready within Mockbin which we have detailed further below.
On this article we have sent in a test order to be able to highlight the full workflow here. Once the order has the status of "Received By Supplier", please head back to the Mockbin URL and select the option "Bin History". This will store all orders while the "Generic API" supplier integration is enabled as shown in the below screenshot. 

To be able to access more information here please expand the order example, you will be able to view the request details and request body. Request body is the one you want to focus on here, an example of this is shown below. 

The Mockbin created will store all of the history so the list of history will grow with each new order as an easy way to review the orders
The "External Body field is very important here - this can be used for clients to send to external devs and this data will be included in reports.
The Request Body JSON is difficult to read so we suggest the use of JSON Parser which we will detail below. 

What Can A JSON Parser Be Used For?

To access the JSON Parsar head to the following URL - http://json.parser.online.fr/
A JSON Parser is  method that "parses" a JSON string, breaking the object down into a more understandable format. In basic English this means you can take your data and turn it into a more readable and logical format. This is to be used in conjunction with your Mockbin and this is a recommended option that will allow you to understand your JSON string easier and to be able to highlight any possible order errors you may find.

Can You Show Me How To Setup The JSON Parser?

At the end of showing you how to set up Mockbin we mentioned the "Request Body", by using the JSON Parser  you can take this data and copy it into the JSON parser. This is an extremely useful tool that allows you to copy and paste the request body and turn the long stringed JSON request into a more readable format. We have shown this in the below screenshot for you to see the readable format. 


We have highlighted the "String Parse" and "JS Eval" - the reason for this is because this has turned your long string into a far more readable format so you can easily see your data. 
This is a very invaluable way of giving the data for what you will get with your orders. It is a good way to test the system and ensure you are getting the right data
The parser wil help you submit API orders and also allow you to figure out any errors. For example if a field was missing from your "Request Body", you would receive an error and the JSON Parser will highlight the error with a "JS Eval Fails"error. The below screenshot shows an example of this. 


The JSON Parser makes it easier to see the problem and you can troubleshoot backwards. 
    • Related Articles

    • Supplier Integration | PMI

      Introduction This article has been created to show how to setup the supplier integration Kornit X has built to connect to PMI.  Setup To setup the PMI supplier integration, please head to your company and within the advanced settings head to ...
    • Supplier Integration | Printful

      Introduction This article has been created to show how to setup the supplier integration Kornit X has built to connect to Printful.  Setup To setup the Printful integration, please head to your company and within the advanced settings head to ...
    • OnPrintShop Supplier Integration

      Introduction This article has been created to show how to setup the supplier integration Kornit X has built to connect to OnPrintShop.  Setup To setup the OnPrintShop integration, please head to your company and within the advanced settings head to ...
    • Supplier Integration | Gelato

      Introduction This article has been created to show how to setup the supplier integration Kornit X has built to connect to Gelato.  Setup To setup the Gelato supplier integration, please head to your company and within the advanced settings head to ...
    • Order Push API - Generic API Supplier Integration

      The Order Push API from Custom Gateway us our generic OMS API allowing us to POST order data in JSON format (matching the structure of our standard orders in API) to an endpoint nominated by a supplier. This is a cheaper alternative to Custom Gateway ...