wso2 dss json format not working - wso2-data-services-server

Can we get JSON in Wso2 DSS directly when we select Output type as JSON in Create Query? I want to know without using curl, can we get? If yes, do we need to configure something extra along with selecting the Output type as JSON. This is because I am able to get data in Xml format from table but JSON throws error.

The request should be an HTTP/HTTPS request with the Accept header as 'application/json'. The following property should be enabled in the axis2.xml ($CARBON_HOME/repository/conf/axis2/axis2.xml). This is enabled by default.
<parameter name="httpContentNegotiation">true</parameter>

Related

Can I have a body and a file in the Form-Data of a http request

I'm working in a Go Lang REST API repo.
I'm wanting to build an endpoint that will take in a file (as part of the form-data, so I suppose I'll use request.FormFile('my-file-key')). This endpoint should also take in a body of a JSON model (which i suppose would be decoded with something like this:
var myData model.MyModel
json.NewDecoder(request.Body).Decode(&myData)
But I'm running into a lot of issues. Is it even possible to send both a body and a file in the form-data with a http request?
If I try to send both I get errors from FormFile saying that it can't find the file of the key name (but if I send the exact same request without a body, this error doesn't happen). I guessing it's having trouble decoding the request.
What you need is a multipart request. One part can be JSON data, and the other part the file data.
If you're using a Go client to prepare the request, you need to use the mime/multipart package to create a Writer, then use CreatePart to create the JSON part, then the file part, and submit the request to the server.
On the decoding side: since the body is JSON you cannot parse it as a form. You have to use a multipart.Reader to read from the body after you parse the headers. Again, from that reader you get a Part, and read the data from that part. You'll get two parts, one for the JSON data and one for the file data.

How do I get Location header in soapui

I have a Http request to get a user level token and I got it to work in Jmeter using Script recorder then , I just copied all values headers and parameters as in Jmeter to SoapUi and created the variables for sessionDataKey to get the same token in SoapUi and it actually don't retrieve the same results on the Soapui Response headers.
I see two differences between the responses in Soap and Jmeter.
For Authorize test step:
In jmeter I can see a Response header " Location " in Soap not (notice this one has the value I need)
example:
Location: https://The Url of the customer/path/path1/#access_token=fdcfb626b142cc1c3575f4eae154f38a&token_type=Bearer&expires_in=70871
For get SessionDataKey test step:
In jmeter I can see a Response header
Set-Cookie: dtCookie=3$C726269DFD45081379EC3D044AEDE19C
meanwhile I cant seem to get those two response headers in Soapui
I dont mind if I dont get the dtCookie value what I really need its the token , but I suspect I need to get the dtCookie value to the Authpart as In jmeter dynamically takes it its not a problem but SoapUi does not make this job
I believe its about some setting in SoapUi preferences
Any Ideas guys ?
Resolved by using another method for token
Yes, you can disable de custom property Follow Redirects:
enter image description here

SAP CPI HTTP Post how to pass token

I need to send a POST in CPI to a s4hana service, and in order to pass it directly in JSON, not in xml, I want to use the simple HTTP adapter.
How can I get the token with a GET and use it with a POST afterwards?
do the GET, parse the XML and save the token as a variable in message header.
Use the message header variable in your POST via filling the JSON with ${header.yourVariableName}
see this:
https://blogs.sap.com/2018/01/18/sap-cpi-clearing-the-headers-reset-header/
http://blog.whint.de/runtime-variables-cpi/

Third party to PeopleSoft SSO integration

I have to write sign on peoplecode to make a service call by passing token (sent from third party) to API and get the responce (if token is valid responce will have username) in json format to create a PS_TOKEN.
I am fresher to peoplecode. How can I run HTTP POST request by passing token and get the response using Peoplecode?
You would create a synchronous service operation in the Integration Broker. The Integration Broker works best if you are sending XML or JSON. If this is just a regular HTTP POST with fields then it can cause some issues with the Integration Broker. I had a similar case and could not get the basic HTTP Post to work but instead ended up using HTTP POST multipart/form-data and was able to get that to work.
Steps I had to do to make this work.
Create a Message (document based or rowset based are both possible)
Create Service Operation and related objects
Create Transform App Engine to convert the Message to a HTTP POST multipart/form-data
Create a routing and modify the connector properties to send the content type of multipart/form-data. Also call the Transform app engine as part of the routing.
The issue with a application/x-www-form-urlencoded POST is that it seems PeopleSoft does another url encoding after the Transform, which is the last time you can touch the output with code. This final url encoding was encoding the = sign in the form post which made the format invalid.
Your other option would be to write this is Java and call the Java class from within PeopleSoft (or mix the Java objects in with PeopleCode). If you choose to go this way then the App Server needs to have connectivity to your authentication server. My only experience with this is I had a client that used this approach and had issues under heavy load. It was never determined the cause of the performance issue, they switched to LDAP instead to resolve the issue.

How can I add custom JSON parameter in JIRA webhook?

I have a web-servise which listens to the JSON requests from different data sources. I want to identify data source by special parameter data-source. My question is how I can add field "data-source": "jira" to the webhook JSON body?
EDIT
For now my solution is to add to my webhook uri http://127.0.0.1:8080/DC data source parameter like this: http://127.0.0.1:8080/DC?data-source=jira, then check data source type and if it is equal to jira send request JSON body to method jiraJsonParser().
But I'm not sure if it is the best solution, isn't it?
I had a similar need, and solved the problem by creating a REST API with flask that acts as an aggregator/translator to accept requests from multiple tools, format the request as needed, and pass it on to it's intended target. For example, I have a Jira 'build request' ticket that sends a POST request via webhook to my API upon ticket creation. The API accepts the request, formats it as needed, fwd's the request on to Jenkins to run a build. As each part of the build runs, Jenkins sends requests back to the API, which get formatted as needed, and the original Jira ticket gets updated with the details/status of the build.
Here's a good article on building a REST API with flask - http://blog.luisrei.com/articles/flaskrest.html

Resources