Linkedin API - OAuth.io - json

I'm developing an application that uses the Linkedin API.
Php for the back-end. I used the library OAuth.io (SDK) and their service but I have a problem: I can't publish an update on linkedin.
I used the syntax provided by SDK with the correct endpoint:
$request_object_li->post('/v1/people/~/shares?format=json', array('commment'=> 'Hello world!'));
I get this response:
Couldn't parse share document.
Unexpected element: CDATA.
According to the Linkedin's documentation I should include into the header these two lines:
Content-Type: application/json
x-li-format: json
How do I put them? The documentation of OAuth.io says nothing about. Someone has already worked with this library?

As shown in https://github.com/oauth-io/sdk-php/blob/master/src/OAuth_io/RequestObject.php#L112, post takes a third parameter headers that can be leveraged as follows:
$request_object_li->post('/v1/people/~/shares?format=json', array('commment'=> 'Hello world!'), array('Content-Type'=>'application/json','x-li-format'=>'json');

Related

how to validate odoo api in postman?

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.

400 Problems parsing JSON - GitHub API and POSTMAN using OAuth

I want to create a file in my private Repo via the GitHub API.
https://developer.github.com/v3/repos/contents/#create-a-file
PUT /repos/:owner/:repo/contents/:path
I'm using Postman for testing and also already authorized via OAuth.
https://api.github.com/repos/user/reponame/contents/test.txt?message=Myfirstmessage&content=SGVsbG8gV29ybGQgaW4gQmFzZTY0IQ==
The error message is: "Problems parsing JSON"
But where exactly is the problem?
I think you have to use choose file from body / binary. I've just had the same problem with creating an issue on github. Putting attributes in body / raw / json solved the problem.

How to specify mime-type in URL to specify JSON from RESTful web service

Can anyone tell me if it is possible to specify mime-type returned from a RESTful web service through the URL? I am trying to demo a simple service that I created to someone and I am just using a web browser (Chrome) to invoke the service. I am trying things like this:
http://localhost:8088/providers?mimeType={application/json}
http://localhost:8088/providers?mimeType=application/json
http://localhost:8088/providers?mimeType=json
None of these work for me - I just keep getting XML returned no matter what I select.
I found several posts related to this subject, but nothing with an answer about how to do this through a URL (I found some which talked about setting headers, but I am using a browser and don't have the ability to specify headers). I found this post:
REST Content-Type: Should it be based on extension or Accept header?
And that post linked to this: http://www.xml.com/pub/a/2004/08/11/rest.html
On the xml.com site, I found this text:
URI-Specified Representation [PS, AR]
A client can specify the representation using the following query string:
mimeType={mime-type}
A REST server should support this query.
So it seems that what I am trying to do should be possible, but I can't figure out how to make it work. Can anyone help?
Thanks.
To define the headers added to your request, you can use a Chrome extension like Postman.
Then you will be able to specify an Accept header to tell Talend to return json:
Accept: Application/json

What is the URL for alfresco CMIS 1.1 queries

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

API 2.0 how to upload file with POSTMAN?

I'm reading API 2.0 documentation and try using POSTMAN (recommended in the documentation).
In "Upload a file" section, I got "404 not found" error.
for example:
{"type":"error","status":404,"code":"not_found","help_url":"","message":"Unknown Error","request_id":"11139828924fa91c0d283d2"}
POSTMAN window image is here.
Base URL is tring "upload.box.com/api/2.0" (temporary, according to the document).
What's wrong?
One more point, your POSTMAN request misses to indicate folder_id in its form data . You need that "folder_id" value for the request to work .
The domain specific Upload issues have all been resolved. You can now direct all API requests, including uploads, to https://api.box.com/2.0