cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a Custom header in Thingworx Connector

Highlighted
Regular Member

Adding a Custom header in Thingworx Connector

NOTE: Even though I have tried on ODataConnector and SwaggerConnector, these steps below should be working for all the Thingworx Integration Connectors viz. GenericConnector, HTTPConnector, ODataConnector, SAPODataConnector, SwaggerConnector, WindchillSwaggerConnector.

 

This document guides you to add a custom header in any Thingworx Integration connector.

Step 1. Create a Datashape say "CustomHeadersDataShape" and add a string field with Name the same as the header name you want to add. In this case, I want to add a header called "Prefer" so it will look something like 

image.png

 

 

 

 

 

 

Step 2: Go to the Integration Connector which you want to add this custom header. Navigate to "Services". Under the "Inherited Services", edit/overwrite the "GetCustomHeaderParameters" service by clicking on the edit (pencil) icon.

Step 3: In the JavaScript Code sniped section add below code snipped

 

var params = {
      infoTableName : "InfoTable",
      dataShapeName : "CustomHeadersDataShape"
};
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var preferValue = "odata.maxpagesize=50";
var newRow = {"Prefer"  : preferValue };
result.AddRow(newRow);

 

Step 4: Save the service and execute "GetCustomHeaderParameters". You should see something like

image.png

 

 

 

 

Now your custom header "Prefer: odata.maxpagesize=50" is set. further execution of your connector services will consider this header until it is reset.

Announcements