How to convert csv to json by WSO2 ESB Smook - wso2

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)

Related

Receiving unstructured data with Business Central web service/api?

I want to expose an endpoint in Business Central which can receive HTTP POST/PUT request and save content of that request into Blob, without any validation. I need that so I can receive json or xml data from external custom services.
I'm not sure how to achieve that since both OData and SOAP expect data to be in specific format and trigger data validation before I can even access POST-ed data.
I've been trying to play with Bound/Unbound actions but still can't figure out a way to access the content of the request. WebServiceActionContext is not well documented and I have not idea what I can or can't do with it. More about that: Microsoft documentation, Tutorial.
Any idea how to read content of a HTTP POST/PUT request is appreciated!
You could create a codeunit with a global procedure and then publish that as your web service.
Something like this:
codeunit 50000 MyUnstructuredWebService
{
procedure PostUnstructuredData(RequestId: Text; RequestContent: BigText);
begin
end;
}
Then you can handle the data directly or save it to a BLOB field in a table for later use.
The trick is to use BigText as the datatype for the parameter containing your actual content.

How to make AWS REST API return a JSON instead of XML

In AWS I invoke the call ListQueues on sqs.us-east-2.amazonaws.com (by calling directly to the REST API)
The response is always an XML, and searching in the AWS documentation I couldn't find how to get a JSON.
Any ideas?
Provide the Accept: application/json header and you'll get a JSON response.
Edit: AWS doesn't have much (any?) documentation on the return types.
I made a pip module that documents some of the return types that may
be helpful as a reference: https://pypi.org/project/awsxmltojson/
Not possible to get JSON response from SQS available actions. Response will always be XML data structures.
In response to an action request, Amazon SQS returns an XML data
structure that contains the results of the request.
Source: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-api-responses.html

How to achieve the dynamic integration pattern in WSO2 ESB

My requirement is I will expose the ESB integration implementation as a REST API.
1) In the implementation part whenever they will call This ESB API it has to route based on content in the post request sent to ESB(this can be achieved by content based routing pattern ).
2) But on the Endpoint side Which is to be called by the ESB while routing based on content may vary means, if today there is 2 end point to call tomorrow it may rise to 5 like that how to apply changes are is there any solution. So, how to achieve this dynamic integration.
I have 4 ways to achieve this integration pattern.
1) Deploy files in the registry which has the endpoint in it and having the file name which is same as the content name(regex) sent in the payload for routing. Then by storing that name in property mediator and use concat function to read that file in another property mediator, and by pattern matching read the endpoint. Thus you can use that endpoint and achieve the dynamic content based routing.
2) Have separate sequence each one to call one endpoint and have the same name as the content name. The main sequence will call the sequence based on the content.
3)Store the content on which to be routed and endpoint in the RDBMS database then use DB lookup mediator to retrieve the endpoint based on this you can route.
4) I think this is best and suitable for integration scenario where tomorrow the endpoint may change( that is when the number of the endpoint is not fixed ) and each endpoint wants a different transformation of the payload(I mean XML to json or JSON to XML etc..).
First, use one API and store the content in property mediator and use that mediator to call another API which has the implementation to call the endpoint.
For example, if the content based on which routing has to happen has the payload like this
{ "content":"c1" }
Store the content in property mediator using name uri.var.address. Then create another API's which will have the implementation to call endpoint(For each endpoint create separate API's) and URI-Template of the API's should have content stored in the property mediator(same as payload request). While using send mediator to call these ENDPOINT implemented API's use http request having url of the API with /{uri.var.address} because to match the URI-template details.

How Qualtrics understands the response

I have implemented a web-service in qualtrics after a question block and the job is to do an operation and send a response back to my website after the survey.I don't know how qualtrics record these responses. Is there any logs section in qualtrics where we can see these responses? Can we deal with the responses in the qualtrics login?
If I'm understanding correctly, you're asking how responses are recorded in Qualtrics WebServices.
When a response comes in, Qualtrics parses the response as embedded data fields. Please note that the response has to be in json or xml encoding for Qualtrics to be able to properly parse it. When you test a webservice it gives you the option to set embedded data based on the response that comes back during testing.
Qualtrics automatically parses your response and assigns it to each parameter.
Either way work. (I didn't test in xml but, I assume it would work as well)
q1=answer1&q2=answer2&...
in JSON {"q1":"answer1", "q2":"answer2", ...)

wso2 esb endpoint can not be changed

I have some external URL (restful api) to be integrated.
Those URL have different prefixed URL with different parameter at url, for example:
www.abc.com/books
www.abc.com/book/11
www.abc.com/book/11/authors
When get response from those invocation, esb needs to convert response from one json format to our standard json format.
I plan to use esb javascript mediator to perform convert operation, but I didn't find any way to attach url parameters.
Any one have any idea?
I have used mediator by java code to implement it, but it is too heavy.
I am also looking into connector for another option.
I have got a solution by use url template. By this solution, I can change url according to template defined.
With this solution, I didn't need to write mediator or connector.