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

How to pass application key in headers for Thingworx 8 version

Highlighted
Regular Member

How to pass application key in headers for Thingworx 8 version

Hi,

can anyone please tell me how to pass application key in headers as parameters, can you post the sample headers.

I tried application key string in headers in many formats, but still I am facing the same issue(cors).

I tried below cases:

headers:{

appKey: <application key>,

ApplicationKey: <application key>,

Application Key: <application key>,

Application-Key: <application key>,

application-key: <application key>,

KEY:<application key>,

}

Thanks in advance .

8 REPLIES 8

Re: How to pass application key in headers for Thingworx 8 version

Have you tried, for example:

"headers": {
    "accept": "application/json",
    "content-type": "application/json",
    "appkey": "your-app-key-here",
    "cache-control": "no-cache",
    "postman-token": "postman-token-here"
  },

Re: How to pass application key in headers for Thingworx 8 version

Hi Polina,

Actually I am consuming thingworx apis from react app.

I am passing the below headers while api calling. correct me if I am doing wrong.

const HEADERS = {

  'Content-Type': 'application/json',

  'Accept': 'application/json',

  'appkey': '73cd42e2-fa9b-4896-b7c4-39780aa0c6d7',

  'cache-control': 'no-cache'

};

do I need to pass postman token also, if yes can you please tell me how to get the postmantoken.

Thanks.

Re: How to pass application key in headers for Thingworx 8 version

appkey needs to be spelled like this - appKey

const HEADERS = {

  'Content-Type': 'application/json',

  'Accept': 'application/json',

  'appKey': '73cd42e2-fa9b-4896-b7c4-39780aa0c6d7',

  'cache-control': 'no-cache'

};

Re: How to pass application key in headers for Thingworx 8 version

Hi Cristina,

I have supplied the appKey same as mentioned in above code, but still getting 404 unauthorized.

I am sending headers as follows:

let default_headers = {

      'Content-Type': 'application/json',

      Accept: 'application/json',

      appKey: <<Thingworx_ApplicationKey>>,

      'cache-control': 'no-cache'

    };

Please help me.

Re: How to pass application key in headers for Thingworx 8 version

The formats provided by others works for me. You do not need the Postman-Token.

Are you sure the appKey you are using has access to the entity you are targeting?

Re: How to pass application key in headers for Thingworx 8 version

Re: How to pass application key in headers for Thingworx 8 version

yes Wes Reading, appKey has access to thingworx.  I am able to access thingworx apis when sending application key as url parameter.

application key has user reference Administrator. I assigned project and model tag to application key. Is it okay to assign project and model tag to application key.

Re: How to pass application key in headers for Thingworx 8 version

That's strange. I had the opposite problem where I couldn't make it work in the header... Maybe try to do it from a command line if you have access to Linux or if you install the windows curl command. This may help in eliminating some questions. The Windows command will be something like this:

GET https://<host><:port>/Thingworx/Resources/EntityServices/ServiceDefinitions -H "Cache-Control: no-cache" -H "appKey: 73cd42e2-fa9b-4896-b7c4-39780aa0c6d7"

Note that depending on your environment you may need one or both of the following options:

-k  : Accept self signed certs

-N --noproxy <host> : Do not go through the proxy if one is configured

From Linux, like this:

curl -X GET \

  https://<host><:port>/Thingworx/Resources/EntityServices/ServiceDefinitions \

  -H 'Cache-Control: no-cache' \

  -H 'appKey: 73cd42e2-fa9b-4896-b7c4-39780aa0c6d7'

Hope that helps gives some clues.

Wes

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________