400 Problems parsing JSON - GitHub API and POSTMAN using OAuth - json

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.

Related

Google OAuth - Incorrect JSON while Validating Access Token

I'm getting an access token from the Android SDK which I'm sending to the server. On the server side, I'm calling the following API to validate my token:
https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=<token here>
From Google, I'm getting the following response (partial response added):
{\"statusCode\":200,\"body\":\"{n \"issued_to\":
\"407408718192.apps.googleusercontent.com\",n \"audience\":
\"407408718192.apps.googleusercontent.com\",n \"user_id\":
\"110586055381870434283\",n \"scope\":
\"https://www.googleapis.com/auth/plus.login
https://www.googleapis.com/auth/plus.me"}
Unfortunately, this JSON is not parseable because of the backslashes & i'm not able to validate the token identity.
Is this a problem with the Google API or do I need to apply any regex?
Google sends back proper JSON without the slashes, being exactly the part that's inside the "body" element of the output that you paste (well without the slashes).
So your Node.js HTTP client is wrapping it with the HTTP status code element and puts in the slashes as well, so your clients need convert back from that on its own.

Linkedin API - OAuth.io

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');

WSo2 API Manager 1.8.0 - JSON parsing issue

I am new to wso2 API Manager, trying to set it up expose my plain HTTP POST back end calls as a REST API. I am sure this is not a new pattern that I am trying to achieve here. The requirement is to convert the JSON data coming in (has array structures) into the HTTP URL query string parameters.
After some research through the documentation and other posts on this forum, decided to go with the script mediator that would parse the JSON data and convert it to a string that can be appended to the endpoint URL. Some how I am not able to achieve this.
I have followed the following post that seems to be very straight forward. As the original poster suggested, I am also not able to use getPayloadJSON() method. Even have trouble using the work around suggested there due to JSON.parse() not working.
Link
Also, this approach of editing the service bus configuration from source view does not sound like the correct option. Is there another elegant solution to achieve this? Thanks for the help in advance.
I was able to get both methods working by using an external script instead of the inline java script. Thanks

Swagger 1.2 endpoint configuration is not loading

Im new Swagger user. I created endpoint with long model definition.
But when endpoint is attached to api-docs, this is not working. I checked that that endpoint configuration file is valid JSON file.
How to check where is the problem with with this file?
Im using Swagger 1.2.
Using bin/validate.sh should be able to help validate the files
https://github.com/swagger-api/swagger-codegen#validating-your-swagger-spec
e.g.
./bin/validate.sh http://petstore.swagger.wordnik.com/api/api-docs "specia-key" ./swagger-errors.html

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