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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Custom headers for swagger connector

dvddhln
7-Bedrock

Custom headers for swagger connector

Hello,

I am trying to setup a swagger connector using a remote swagger file located on another server. However, after mapping some of the services I am still required to add some custom headers to the request to the remote service. How do you add your own custom headers to the outgoing requests?

 

Thanks

ACCEPTED SOLUTION

Accepted Solutions
dvddhln
7-Bedrock
(To:dvddhln)

Well, I figured out this one on my own.

I added a swagger thing which uses the swagger connector. I then overrided the "GetCustomHeaderParameters" and returned a result similar to this

 

var result = { dataShape: { fieldDefinitions : {} }, rows: [] };

result.dataShape.fieldDefinitions["header"] = {

name: "authorization",

baseType: "STRING"

};

result.rows=[{"authorization":"Bearer randomTokenString"}];

 

Which is a response just with one row.

 

Notice that it should be lowercase "authorization". You can add your custom headers aswell to your liking like x-custom-header. This is then used by the underlying httpclient in thingworx integration run time.

 

Laterz

View solution in original post

1 REPLY 1
dvddhln
7-Bedrock
(To:dvddhln)

Well, I figured out this one on my own.

I added a swagger thing which uses the swagger connector. I then overrided the "GetCustomHeaderParameters" and returned a result similar to this

 

var result = { dataShape: { fieldDefinitions : {} }, rows: [] };

result.dataShape.fieldDefinitions["header"] = {

name: "authorization",

baseType: "STRING"

};

result.rows=[{"authorization":"Bearer randomTokenString"}];

 

Which is a response just with one row.

 

Notice that it should be lowercase "authorization". You can add your custom headers aswell to your liking like x-custom-header. This is then used by the underlying httpclient in thingworx integration run time.

 

Laterz

Announcements


Top Tags