Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create device type using API #1364

Open
wmmihaa opened this issue May 8, 2017 · 2 comments
Open

Unable to create device type using API #1364

wmmihaa opened this issue May 8, 2017 · 2 comments

Comments

@wmmihaa
Copy link

wmmihaa commented May 8, 2017

  1. I've created a Standard Application API Key
  2. Using Postman, I set Basic Auth using the key as username and token as password
  3. Successfully call https://[myorg].internetofthings.ibmcloud.com/api/v0002/device/types using the GET verb
  4. Failed calling the same uri as above using POST with this payload:
    { "id": "myDeviceType", "description": "My first device type", "classId": "Device" }

Response: 403 Forbidden

Nor can I create a device...
I've also tried the same using Operations Application Key

BTW... I'm currently using the free option if that has anything to do with it...

@slaupster
Copy link
Contributor

slaupster commented May 10, 2017

@wmmihaa The problem with Postman is that it is built on Chrome, and Chrome is inserting additional headers. In particular it sets the Origin header. Due to the CORS implementation in IoTP, when the Origin is set by Chrome (to localhost maybe?), the request is forbidden because it does not match the allowed origin (https://[myorg].internetofthings.ibmcloud.com).

CORS support prevents malicious abusing of the session when logged into IoTP. Applications do not need to worry about this, because typically they would not set Origin header. eg. curl works fine:

curl --user 'apikey:token 'https://orgid.internetofthings.ibmcloud.com/api/v0002/device/types' -H 'Content-Type: application/json' --data '{"id":"mytype","classId":"Device"}'

Unfortunately you cannot specify the Origin header with Postman. You could try Advanced Rest Client (ARC) - https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo

@CaroMac
Copy link
Collaborator

CaroMac commented May 11, 2017

@wmmihaa I hope that this response has helped you to resolve the issue you were having. If you have future queries, then a good place to go is developerWorks Answers, where you can ask a question and view other questions that have been asked. The link is here: https://developer.ibm.com/bluemix/support/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants