What is the URL for alfresco CMIS 1.1 queries - json

I'm trying to figure out how to use the new browser binding in Alfresco 4.2. I get that the service URL is
https://server.com/alfresco/api/-default-/public/cmis/versions/1.1/browser
And I'm able to do requests for objects and paths in a restful manner
https://server.com/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/Sites
https://server.com/alfresco/api/-default-/public/cmis/versions/1.1/browser?objectId=xxx
But what I don't understand is how to translate the specification's "selectors" and "actions" into URLs. For instance, I have no idea what the URL for doing a "query" is.
http://docs.oasis-open.org/cmis/CMIS/v1.1/cs01/CMIS-v1.1-cs01.html#x1-5540003
I've tried all of these to no avail:
https://server.com/alfresco/api/-default-/public/cmis/versions/1.1/browser/doQuery?q=select ...
https://server.com/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/doQuery?q=select ...
https://server.com/alfresco/api/-default-/public/cmis/versions/1.1/browser?cmisaction=query&statement=select....
https://server.com/alfresco/api/-default-/public/cmis/versions/1.1/browser/cmisselector=query&q=select...
I think I'm having trouble reading the specification. The specification lists out a bunch of "selector" and "actions" for named URLS (service url, repository url, object url, etc). But doesn't explain how those are to be formed into URL strings.

You can execute a query with HTTP GET and HTTP POST.
A HTTP GET URL end with: .../browser?cmisselector=query&q=select...
For A HTTP POST example see:
http://docs.oasis-open.org/cmis/CMIS/v1.1/os/examples/browser/doQuery-request.log

Related

Retrieve values from a nested response in Postman

I am using postman to get certain responses. Below is my response.
Here I have some other api request links integrated with this response. Is there any possibility that I can get values inside these apis also. Its like retrieve values forom both parent api request and child api request.
I know this is possible using a java code. But is there any other exsiting software that I can use for this?
In your case I would recommend combining multiple requests into a chain or even a workflow. The idea is to have the first request fetch href endpoints that get called in subsequent requests. For that, the initial request needs a post-request test script that reads the href values from the response and stores it in a environment or global variable.
Like so:
// persist project href for next request
pm.environment.set("projectUrlPath", pm.response.json().embedded.elements[0]._links.project.href);
Your next request in the line would than use this variable to build the request url. Like so:
http://www.example.com{{projectUrlPath}}
The key is to correctly navigate to the right attribute in the response json JavaScript object. This online tool might help you with that:
https://www.w3schools.com/js/tryit.asp?filename=tryjs_json_parse

How to tell SharePoint 2010 listdata.svc to return JSON via URL?

I need the following URL to return JSON:
https://mysite/_vti_bin/listdata.svc/Pages
I've tried added the following to the URL (per a blog online but didn't work):
https://mysite/_vti_bin/listdata.svc/Pages?format=JSON
It always returns XML. Also, I'm not calling the web service via C# or JS code. I'm using a rapid app dev platform that has built-in API consumption. All I need is JSON to be returned (given a URL structure) and I got what I need. Thanks.
By default SharePoint 2010 REST service returns results in XML format. To get the results in JSON format, include an Accept header set to application/json;odata=verbose.
Example
url: http://site url/_vti_bin/listdata.svc/ListName,
method: GET
Headers:
accept: "application/json;odata=verbose"
Result

HTTP JSON and REST

Does JSON messages sent over HTTP in response to a URL request make it REST-compliant?
I believe it is not.
But I am not sure on the detailed reason.
If i have a well-organized website,which responds to URL requests with json representation payload - what does it need to do further to comply with RESTful or JAX-RS?
A simple concise explanation will be much appreciated
There is no restriction regarding the payload of messages in REST and using JSON format in HTTP responses isn't enough to make a service RESTful.
To make short (since it's what you asked for ;-)), what is really important in REST is to respect the HTTP operations (GET, POST, ...) are designed for, the concept of resources and their states (idempotence, ...), leverages headers and status codes, ...
The following link could give you hints about the way to implement a RESTful service / Web API:
Designing a Web API - https://templth.wordpress.com/2014/12/15/designing-a-web-api/
Hope it helps you,
Thierry
JSON is a payload and does not play any role in making your Webservice REST-complaint.
Payload could be XML, CSV, plain text etc etc.
The Webservice will be REST-Complaint when it's following REST protocol (set of rules, not network protocol).
There are up to 4 levels where you can make your REST webservice complaint to.
One of the very basic rules to understand is that - Your Request must not be RPC i.e. you MUST not perform any action using a Payload (Typical SOAP) or URL tunnelling e.g. http://www.example.com/product?id=1234&action=delete
In RESTful world you would define one top level URI for the above. e.g. http://www.example.com/product
and then you will call various URLs to perform other actions.
Such as:
POST - create Data
http://www.example.com/product
Body{ here your payload will describe the Product.}
Assuming you rely on server gennerated product id then return type could be Product Id. Which is again should be set as LOCATION parameter of the return header.
PUT - Update Data
http://www.example.com/product/1234
Body{ here your payload will contain the Product details to change.}
GET - Get Data
http://www.example.com/product/1234
DELETE - Delete Data
http://www.example.com/product/1234

RESTful web service url html vs json

To generate urls for accessing data for customers, I follow the specification:
Deliver all JSON data pertaining to customers at the URL: wwww.somesite.com/customers
To create, update or delete, use the www.somesite.com/customers/ url with the appropriate verbs i.e. POST, PUT and DEL respectively
However, I want to provide an html page also (preferably at www.somesite.com/customers) which accesses all the JSON data via AJAX calls.
Should I respond at the same url (www.somesite.com/customers) with HTML or JSON based on the headers in the requests? Or is there a better/standard way to do it?
Using headers is tricky to work with. Imo it's best just to use a predictably different url for the api. Such as:
www.somesite.com/customers.json
api.somesite.com/customers
www.somesite.com/api/customers
www.somesite.com/api/v1/customers
As per REST principles the URL indicates the resource and the response is the representation of the resource.
You can generate different representations (JSON or HTML) for the same resource base on client specified criteria. This can be specified through the Accept header item or the Query string.
It is possible.
You can look inside the request if it's an xhr-Request e.g. in express.js it's located at ``req.xhr`. Depend on if it's true you can deliver HTML or JSON.
app.get('/customers', function(req, res){
if(req.xhr){
res.type('application/json');
res.send({});
}else{
res.type('text/html');
res.send('<html>...</html>');
}
});

wso2 esb json post method blank query parameter handling

I converted JSON (client) to SOAP (back end) through ESB Proxy Service and it is working fine.
URL "https://someurl.com/json/"
The problem is that I am trying to call from another batch process application (Mirth) and it is adding "?" end of the URL changing the URL to "https://someurl.com/json?" How can I get rid of the "?" character?
This article contains information on how to customize URLs.
This is also possible using Script mediator - these can also be used for URL transformations.