how to validate odoo api in postman? - json

I want to generate a rest api in odoo so that it can be used in other languages. I have used below api's
http://URL_with_PORT/{}/xmlrpc/2/common
http://URL_with_PORT/{}/xmlrpc/2/object
but when I validated it using postman it is giving me error.

You don't need the curly braces in the URL. Just send it to the xmlrpc/2/common endpoint, as per...
http://<server:?port>/xmlrpc/2/common
You need to set the verb to POST, and the body to raw with XML.
Then send in the following XML in the form as per the documentation.
<?xml version='1.0'?>
<methodCall>
<methodName>version</methodName>
</methodCall>
This will return the server version info as per the examples used in the External API documentation in an XML response.

Postman isn't the best client to use XML-RPC calls, take a look at XML RPC GUI for developers in Windows?. You have to create a raw request and then send it. Using SoapUI would be much easier.

Related

Why am I getting XML results from the Exact Online API where I used to get JSON results?

Just started working on an existing project making use of the Exact Online API.
While I was debugging the project I suddenly only started receiving XML results instead of JSON results from the API. I did not change anything about the endpoints being queried I was just running the existing queries trying to figure some things out.
These are the REST API docs: https://start.exactonline.nl/docs/HlpRestAPIResources.aspx
These are the XML docs: https://support.exactonline.com/community/s/knowledge-base#All-All-DNO-Content-xmlsamplecode
Typical REST API endpoints look like this:
https://start.exactonline.be/api/v1/xxxxxx/salesinvoice/SalesInvoices
Typical XML endpoints look like this:
https://start.exactonline.be/docs/XMLDownload.aspx
I also did not change any settings. I only have access to the tokens and api. I don't have access to the account.
This is an example of an endpoint and query where I previously received JSON but am now receiving XML:
https://start.exactonline.be/api/v1/xxxxxx/salesinvoice/SalesInvoices?$filter=InvoiceID eq guid'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx'&$select=InvoiceID
I tried this manually with Postman and also using the existing code from the project.
Is there some setting I am unaware of? Am i querying the wrong way? Maybe there have been some changes to the API I am unaware of that aren't listed in the release notes?
Please provide the request header Accept in your HTTP request that specifies what content format you prefer to receive: application/json. The default of Exact Online APIs is XML (but seldom to never used).

validate incoming JSON requests in wso2 api manager 2.6.0

I need to validate incoming json requests structure in wso2. I will be able to validate incoming json using default json validator in mediation sequence, but I want to apply json validation only for POST request and not for GET request in an API. It can be achieved by adding custom in flow sequence.
I'm having json validator file for schema validation(like jsonvaldiator.json).
Where should I keep this file in wso2 api manager 2.6.0 and how to mention the validator file path in filter added in the custom in flow sequence?
Any comments would be appreciated.
Yes, you need to add a custom In sequence to the default message mediation flow in order to achieve this. Please have a look at this blog post about validating JSON request payload. This might help to do this for APIM-2.6. Because the blog has been written for an older version but you can get the idea. :)
More about WSO2 Gateway Extensions. https://dinushasblog.blogspot.com/2018/04/wso2-api-manager-gateway-extension.html

How to consume REST Endpoint with wso2 api manager?

I can consume SOAP APIs in my company with wso2 api manager. However when I want to consume REST endpoints I am unable to do so. I keep getting no response.
My endpoints are like such:
GET: http://{server}:{port}/api/broker/{brokerId}
POST: http://{server}:{port}/api/addresscleanse with json payload.
I am not seeing any configuration for the backend point where we can specify that the backend service is expecting json payload or queryparameter. I tried to scan the tutorial section and did not find any thing similar to my need.
Any help would be appreciated.
You can define your resources like below. To specify the message body type of the POST request, you can send Content-Type header.

Call rest service that returns JSON in mule esb?

How to call a rest service that returns JSON in a APIKit based message flow. I want to prepare the request for Rest service and want to extract the JSON message in a message flow.
Can any one help me to do this?
Thanks
The recommended way to invoke/consume REST services in mule is the use of HTTP Request
Do let us know if there is a specific you are facing
The request connector is especially handy when consuming a RESTful API
that is described in a RAML file. If you reference the API's RAML file
in the connector's configuration, it will proactively offer you the
set of available resources and operations contained in the RAML file,
as well as enforce the policies described in the file. It will also
expose the API metadata to Studio, which can then be used by other
elements such as DataWeave to autocomplete fields and make
configuration much easier
Use Rest URI path to invoke the Service and you can also get json response as output based on the type of service you invoke

REST Service testing - SOAP UI

I need to add JSON format parameters to request payload to do a POST request in restful service testing. How can I do that in SOAP UI?
You did not specify which version of SoapUI you are using. In version 4.x of SoapUI, they made the same assumption as what FrAn answered: you generally do not want to include a payload for a GET request. In later versions of SoapUI, they corrected this and you are able to do it.
Once you change the method type to POST, on the individual method call, you will see another panel where you are able to define the body. You can see this in the documentation. You will have to write out the entire body manually.
For REST services, the payload is not part of the WADL - which SoapUI uses internally to store the entire definition. You can create a sample Request in your REST service to make creating test cases easier. You can see this in the documentation.
Lastly, some additional information is available in the API Dojo.
HTTP GET request shouldn't contain payload. While you can do that, insofar as it isn't explicitly precluded by the HTTP specification, I would suggest avoiding it simply because people don't expect things to work that way.