< class="prominent-subhead ">

SmartObject REST Endpoint  Broker Behavioral Change

~~repeating-content.html~~

This article discusses a behavioral change in the  SmarObject REST Endpoint  Service Broker between K2 blackpearl 4.7 and K2 Five, versus K2 Cloud and K2 Five Fix Pack 18. 

Issue

In some versions of the REST EndPoint Service Broker, the broker only used Application/JSON as the default Content-Type and Accept header values. This would cause a service that required application/JSON;odata=verbose being passed as the Content-Type to fail, as not all Rest Headers for "odata=verbose" content types passed through to the Swagger file via the httpHeader Object. In K2 blackpearl 4.7 this worked as expected since the broker accepted text/JSON Content-Types.

Symptoms/Error Message

403 Forbidden error occurred in a Fiddler trace, and you may see a 415 Unsupported Content Type error.

Behavioral Change

In K2 blackpearl 4.7 and some versions of K2 Five (prior to applying K2 Five Fix Pack 18) and K2 Cloud, the SmartObject REST Endpoint Broker allowed for text/JSON as a supported Content-Type. In K2 Five Fix Pack 18 and K2 Cloud, changes were made to use the Accept and Content-Type information from the swagger file where the values in the swagger file are sent as headers, as follows:

"produces" = "Accept”,
"consumes" = "Content-Type"

If the produces and consumes headers are not present in the swagger file, then application/json is used by default. The ability to pass these values in using the header was also added, overriding the default and the swagger file values.

  • If the MIME type is not provided the MIME default of application/json is set. In other words, if there are no produces or consumes tags set and no headers passed, then the broker continues to set the value to application/json.
  •  If the Swagger configures the produces or consumes tags, the broker uses these values instead of the defaults.
  • If the Header provides Accept or Content-Type values, the broker uses these values instead of the defaults.
  • If both the Swagger and the Header are provided, the broker uses the Header values.

The table below summarizes scenarios and expected results:

HTTP Verb

Swagger: nothing passed
Header: nothing passed

Swagger:
"produces": ["application/json;odata=verbose"]
Swagger:
"consumes": ["application/json;odata=verbose"]

Headers:
Accept:
application/json;odata=verbose
Content-Type:
application/json;odata=verbose

GET

Accept: application/json
Content-Type: {ignored, not passed}

Expected
Accept: application/json;odata=verbose

Actual
Error: Service action does not support JSON response.

Accept:
Content-Type: {not passed}

Accept: application/json;odata=verbose

Content-Type:
application/json;odata=verbose

POST, PUT, PATCH, or DELETE

Accept: application/json
Content-Type: application/json

Expected
Accept:
application/json;odata=verbose

Actual
Error - Service action does not support JSON response. 


 

Expected
Content-Type:
application/json;odata=verbose

 Actual (*)
Content-Type:
application/json
(*Fix included in Fix Pack 18)

Expected
Accept:
application/json;odata=verbose
Content-Type:
application/json;odata=verbose

Actual
Accept:
application/json;odata=verbose
Content-Type:
application/json

Resolution

If you receive the 403 Forbidden error occurred and/or 415 Unsupported Content Type errors, or notice the different header values, update the Swagger file to use the correct values. If you cannot update the Swagger file, use the default Header options in the SmartObject REST Endpoint Broker service instance to send the correct values.