RestAPI: Content-Type header should not be required for GET

Thursday, July 13, 2023
Avatar

Using the v6.0 RestAPI, and trying to GET data from Spira  in json-format, the API requires that the Content-Type header is set to application/json.

Clearly, it should be the Accept header that should be conveyed with the application/json value. 

Example: 

curl --user <username>:<password> -H "Accept: application/json" https://spiraservice.net/Services/v6_0/RestService.svc/projects/9/releases 
returns a 400 Bad request error

while:

curl --user <username>:<password> -H "Content-Type: application/json" https://spiraservice.net/Services/v6_0/RestService.svc/projects/9/releases 
returns a 200 OK with the requested data.

Why does it matter?

Trying to send a GET request with a Content body (required to set the content-header) using a .NET HttpClient, throws:

ProtocolViolationException {"Cannot send a content-body with this verb-type."}

Getting Microsoft to change this behavior is probably not possible, but the Spira API should correctly handle the Accept header instead of the Content-Type header here.

 

 

 

1 Replies
Thursday, July 13, 2023
Avatar
re: bjorn_dmab Thursday, July 13, 2023

It is because we are using a Microsoft WCF to implement the web service layer and we have to dynamically support both JSON and XML, so we need to use the Content-Type header to know which to use.

So unfortunately we're also limited by Microsoft as well ;-)

Spira Helps You Deliver Quality Software, Faster and With Lower Risk

And if you have any questions, please email or call us at +1 (202) 558-6885

 

Statistics
  • Started: Thursday, July 13, 2023
  • Last Reply: Thursday, July 13, 2023
  • Replies: 1
  • Views: 283