"A ruleset parameter of type XML is not supported in a JSON payload" exception when using the Business Rules service on Bluemix - business-rules

I tried to use my XML data with the HTDS REST JSON API and I got the exception:
"A ruleset parameter of type XML is not supported in a JSON payload"

I was trying to use the XML binding object model, which is not supported in the JSON format.
Once I switched to the XML format, the error disappeared.

Related

415 unsupported media type content-type application/pgp-encrypted while sending POST message

I'm working in REST API development project. The client have provided the OpenAPI specification for the API which they are expecting.
We have used the openAPI generator cli to generate the API from the OpenAPI specs given by the client.
Following are the two APIs
1. /requestFile:
This API is expected to accept JSON payload and produces payload of content type application/pgp-encrypted.
We have annotated the API as below.
#postmapping(value="/requestFile",consumes={"application/json"},produces={"application/pgp-encrypted"})
The expectation is to transfer a PGP encrypted JSON file as a response to the POST message.
I'm not sure how to transfer the PGP encrypted file as a response, I have searched for some references but most of them are using maultipart file to transfer binary files. Whereas the content type of multipartfiles is not same as "application/pgp-encrypted".
I need some help in transferring this pgp encrypted file as a response to the POST message via REST API.
2. /feedback
This API consumes payload of type application/pgp-encrypted and produces a simple http response code back to the client. We have annotated the API as below.
#postmapping(value="/feedback", consumes={"application/pgp-encrypted"})
When I try to send a POST message using POSTMAN with content type application/pgp-encrypted, we are getting a 415 unsupported mediatype error.
I need to understand how do we send pgp-encrypted file as a payload via POSTMAN and what is the content type I must use to achieve this.

Is there an available messageFormater or messageBuilder for contentType binary/x-gzip in WSO2?

Currently having an error Invalid UTF-8 start byte 0x8b (at char #2, byte #-1).
The response is currently zipped and would like to know how to transform the received message into xml format. The response for the service at soapUI has a Content-Type: binary/x-gzip.
What can be the messageFormater and messageBuilder in WSO2 in order to parse the data received? Or, what type of property should be used?
You have to use BinaryRelayBuilder and ExpandingMessageFormatter to just pass data through the ESB without built or formatted. This message builder and message formatter need to added into the axis2.xml file located in <EI_HOME>/conf/axis2 directory.

convert JSON input to form-data in AWS application gateway

Our old legacy APIs accept the data only in form-data format, but I am required to send my data as JSON in body of request. So, how I can convert my JSON (application/json) input to form data in AWS Application gateaway.
I have input parameter like this
{"key1": "val1", "key2": "val2"}
I tried many solution with template mapping and query string parameter but they didn't work for me maybe I am doing something wrong. Above configuration is fully supporting form-data.
Note: Due to some reason I don't want to change my legacy django code to handle JSON input instead of form data.
I would suggest looking at the structure of a raw POST form-data request. Then you should be able to structure the Integration Request to fit the form-data format using the right Content-Type and mapping template.
There is an example for GET and an example for POST on this page (with the caption "the HTTP request looks like this") https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Sending_and_retrieving_form_data

How to convert csv to json by WSO2 ESB Smook

I need complete two Task; At the first,read CSV file by VFS Transport,convert to JSON, then Call Rest API insert to DB in the end;But I feel puzzled,How to Mapping Data Format
This blog post has somewhat similar usecase with some example configurations. (you'll need to modify/extend it to support json and call the rest service)

How to send Queryparam with JSON value using Jersey client in unit test

I am trying to write a test case for a jersey resource using InMemory container provided by Jersey.
As my service method contains many multivalued parameters as filters, I opted to send all of those values as single JSON parameter, so that it will be easy to send a list of values for each filter.
When i send the JSON string using target("path").queryParam("filters", jsonString).request().get(); the call fails die to Jersey clients internal query builder, which is parsing the url and checking for path param templates in the url. Since the url contains my JSON with "{" in it, they are interpreted as path param.
If I try to encode the JSON using URLEncode.encode(jsonStr, "UTF-8"), the path param template issue is solved but white spaces in JSON are received by server as "+" as jersey client encoding URL one more time, but server decoding it only once.
If I make the Queryparam as post param test is working, but i don't want to use POST for just to retrieve data.
I can't post original code due to company policies.
My question is, is there any way to disable path template check in jersey clieny by setting custom builder.
A simpler solution would be to replace the '+' by '%20' as suggested here and here:
URLEncode.encode(jsonStr, "UTF-8").replaceAll("\\+", "%20");