Sending the post method contents in REST invocation from WSO2 ESB - rest

I have been trying to invoke a rest operation from my wso2 ESB and was successful in invoking the rest post method from WSO2 ESB. But, un luckily i was not able to access the data that i posted, neither through request parameters nor through request attributes.
PS: I don't want to frame a get kind of URLs for my post request.
is there a solution to this ?

You need to use the correct content type so it will preserve POST request data.This post will help you to understand the reason.
Edit.
1) Add the following entry to axis2.xml in message builders.
<messageBuilder contentType="application/x-www-form-urlencoded"
class="org.apache.synapse.commons.builders.XFormURLEncodedBuilder"/>
2) then access the required parameter in esb using
<property name="NameOfTheProperty" expression="//xformValues/NameOfTheProperty/text()"/>

Related

How to call REST API related to Azure Search through postman?

I am trying to call REST API related to Azure Search through postman.
Here is the API link: (Check Step 1: Create a data source)
https://learn.microsoft.com/en-us/azure/search/search-howto-indexing-azure-blob-storage
Have sent parameter api-key: [admin key] in form-data and other through jSON object.
I am getting 403 error.
Whats the correct way to get required output?
Update :
Changed position of api-key. Still getting the error as :
Is there any additional setting for postman to work with Azure's REST APIs?
Please make sure that you pass api-key in Headers instead of form-data and also all the headers should be selected. Once you do that, things should work just fine.

Using JSON Search Queries with a GET request in JMeter

My org is trying to use JMeter as part of a test automation suite to test some back end REST APIs. Currently one of them supports using JSON queries as a way to get filtered results back from a GET request.
We are using the JMeter UI to create these tests and since all the other API calls work under the HttpClient3.1 HTTP Request implementation that is the implementation that I am currently using to get this to work. With this implementation I get the following when looking at the failure in the results tree (response data portion) I have made the error slightly more generic to protect some IP:
java.lang.IllegalArgumentException: Invalid uri 'https://server:port/restservice/v1/users?firstname_query={"in":["User1FirstName","User2FirstName"]}': Invalid query
at org.apache.commons.httpclient.HttpMethodBase.(HttpMethodBase.java:222)
at org.apache.commons.httpclient.methods.GetMethod.(GetMethod.java:89)
at org.apache.jmeter.protocol.http.sampler.HTTPHC3Impl.sample(HTTPHC3Impl.java:229)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1146)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1135)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:434)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:261)
at java.lang.Thread.run(Unknown Source)
I have also tried the same request using the Java implementation and get a similar result.
If anyone has any ideas or if you need more information let me know and thank you again in advance for any help you may be able to provide.
Your HTTP Request configuration is a little bit incorrect. JSON entities contain braces {} which are not allowed in URLs so you need to encode them.
Configure your HTTP Request sampler like:
Make sure "Encode" box is ticked.
And this way you will be able to send JSON with HTTP GET Requests. You can use View Results Tree listener to inspect request and response details:
You might also need to add HTTP Header Manager to your Test Plan and configure it to send Content-Type header with the value of application/json. See Testing SOAP/REST Web Services Using JMeter article for more details on properly configuring JMeter for testing REST APIs.

Why am I getting request method GET not supported?

I am using PostMan as a REST client to test this API method Cisco ACL Analysis API. specifically POST /acl/trace or getAClTracksStd (first go to Policy Analysis)
Here is my PostMan HTTP test call
Does anyone who is familiar with PostMan understand why I am getting this "Request method 'GET' is not supported" error from the server? I am making a POST HTTP request, not GET.(Selected from Drop down menu) It make more sense for me to get a input invalid parameter error or something.
Just to show that the endpoint url works, heres a HTTP test request that works
(same link, host->host API -> GET /host/{startIndex}/{recordsToReturn}
There's two issues that I'm seeing with your REST call. First, the error you're seeing is because the call needs to be preceded by "https://". Second, remove the interface IDs parameter and values. You should get a response with data after making these changes.
Your json looks erronuous (comma after the destIp) - and the server probably always responds with a default confusing error message in this case. (Postman is very well tested and it sends POST).

RESTful post in Oracle Service Bus

Does anyone know how to create a proxy service that will handle this sort of thing?
What I'm looking for is a path parameter and a post body being formatted similar to this:
POST www.myurl.com/{123}
Post body:
myId=1&myOtherId=2
I am currently passing in an XML document and I'm doing an insert on the http:relative-URI element in the transport. This seems to work.
I am also currently doing an insert on the http:query-parameters for my post body name/value pairs.
I am inserting these on the outbound variable. When I debug, both are showing up and I'm contacting the REST service. I am getting a 400 -- Bad Request error. This happens when the post body is not configured correctly.
Any ideas how to do this?
If you are just Posting an XML, then while creating Proxy Service, Select Service Type as Any XML.

Create WSDL message from SOAP Response

I have a WSDL that contains a different response then the actual responds with. I want to update the WSDL with the format of the API response but am having trouble. Is there a tool to generate a WSDL response from SOAP XML?
I should mention that they gave me the WSDL as a file, no public WSDL is visible.
The response contains this unknown anonymous xml element, s-gensym3. It should be userid.
If it's a .NET web service you can browse to [serviceurl]?WSDL to get the WSDL.
There's surely service endpoint you communicate with. You shall be able to invoke this endpoint in the browser and add to the end:
?wsdl
i.e. http://service:8123/operationName?wsdl
This will print you entire WSDL. Just make sure you have the same and you're done.