1

I am testing Forge API, and I have been able to complete requests smoothly for most endpoints, except the GET Hubs - I kept getting a 415 Unsupported Media Type.

Strangely enough, after I remove the Content-Type header - which was the same header used for all the other end-points of Content-Type:application/json - the request worked and returns a 200 with the correct data.

Is there something about content-type I am not familiar with? Shouldn't the first request work?

Request 1 - Returns 415 for hubs endpoint: no data
GET https://developer.api.autodesk.com/project/v1/hubs HTTP/1.1
Host: developer.api.autodesk.com
Authorization: Bearer {{ACCESS_TOKEN}}
Content-Type: application/json
Cache-Control: no-cache
Request 2 - Returns 200: data ok
GET https://developer.api.autodesk.com/project/v1/hubs HTTP/1.1
Host: developer.api.autodesk.com
Authorization: Bearer {{ACCESS_TOKEN}}
Cache-Control: no-cache

Request 1 Request 2

gtalarico
  • 4,409
  • 1
  • 20
  • 42
  • You don't need to pass content-type to make request to GET apis. Only POST or PUT apis would need that to indicate the format of the payload. – Chetan Mar 15 '17 at 03:06
  • Of course. Thank you, that makes perfect sense. I guess I got confused because some of the other GET methods went through with the header, so I just assumed needed to send it. – gtalarico Mar 15 '17 at 07:22
  • GET APIs should normally ignore the content-type headers even if they are passed. The issue is reported to the API team. – Chetan Mar 15 '17 at 09:27

2 Answers2

2

The JSON API defines that the client MUST send Content-Type: application/vnd.api+json

LuFFy
  • 8,799
  • 10
  • 41
  • 59
bob
  • 21
  • 2
  • I'm not sure if this is entirely correct if you look at the [request examples](https://jsonapi.org/format/#fetching-resources) it would seem the `Content-Type` is not necessary. The [Content Negotiation](https://jsonapi.org/format/#content-negotiation) requirement seems to contradict the request examples. – Adam Rodriguez Aug 27 '19 at 15:55
1

Answering my own question based on the comments (thanks @chetan-ranpariya)

  1. You don't need to pass a Content-type on GET requests
  2. the API should ignore the header; issue has been reported to API team
gtalarico
  • 4,409
  • 1
  • 20
  • 42