REST Broker gives a 415 HTTP code when text/json is used instead of the correct application/json
kbt177328
PRODUCTIssue
When trying to call a REST SmartObject that has been used previously, a 415 HTTP Status code is returned. This means unsupported media type. In this case it is text/json as opposed to application/json.
According to http://www.iana.org/assignments/media-types/media-types.xhtml that is not a supported value for JSON.
The supported value for Content-Type value for JSON payloads is: Content-Type: application/json
By supplying custom headers with in the HttpHeaders property of the SmartObject using the standard content type value the 415 error can be bypassed.
Symptoms
A 415 HTTP code is seen in a Fiddler trace when calling the smartobject.
HTTP Error Code 415
Resolution
The Swagger file needs to be changed to allow application/json instead of text/json.
The 415 can be bypassed using the following value to force application/json in the header.
Here is the value being passed:
{"$type": "SourceCode.SmartObjects.Services.Endpoints.Common.HttpHeader[], SourceCode.SmartObjects.Services.Endpoints.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null", "$values": [ { "$type": "SourceCode.SmartObjects.Services.Endpoints.Common.HttpHeader, SourceCode.SmartObjects.Services.Endpoints.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null", "Name": "Accept", "Value": "application/json" }, {"$type": "SourceCode.SmartObjects.Services.Endpoints.Common.HttpHeader, SourceCode.SmartObjects.Services.Endpoints.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null","Name": "Content-Type","Value": "application/json"} ]}