I'm working on a PayPal payment integration using a Java Springboot microservice where in an order is created on PayPal, i'm retrieving the order details from the paypal successfully. Now I want to update the order in the PayPal by adding an attribute invoice_id. But, when the Update Order(PATCH) is being called, Paypal throws a bad Request.
Doc link : https://developer.paypal.com/docs/api/orders/v2/#definition-order_capture_request.customized_x_unsupported_3218_order_application_context
PATCH https://api-m.sandbox.paypal.com/v2/checkout/orders/{{order_Id}}
Request :
{
"op": "add",
"path": "/purchase_units/#reference_id=='default'/invoice_id",
"value": "123456"
}
Error Response: [{"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"1ef2afd17aa1p", "details":[{"field":"/","location":"body","issue":"MALFORMED_R... (421 bytes)]
Can someone help me on this please.
I tried out multiple things like changing the request body. But, it doesn't seem to be working.
Related
I am trying to integrate the YELP API within an application in Android Studio. I am trying to acquire an access token using a post request in Postman. However, when I send the post request I get this error returned in JSON format:
{
"error": {
"code": "VALIDATION_ERROR",
"description": "'client_credentials' is not one of ['authorization_code', 'refresh_token']",
"field": "grant_type",
"instance": "client_credentials"
}
}
I have searched this site and google for what the description line means in particular:
"description": "'client_credentials' is not one of ['authorization_code', 'refresh_token']",
I have not been able to find any results as to what this error means. Here is my project setup in postman:
I simply copy and pasted my client ID and API key from yelp and stored them within the client_id and client_secret in Postman respectively. When I send this requestion I get the 400 Bad Request error and find out that its a validation error. At first I thought that I entered the wrong API key, however, I refreshed the API key and directly copy and pasted it, so I am confident that my API key and client ID are correct. The output should look like this and it should deliver an access token:
I couldn't find any examples that had this specific error message.
You no longer need a refresh token, all you need is an API key in your Authorization header:
Authorization: Bearer {{apiKey}}
Source: https://www.yelp.com/developers/documentation/v3/authentication
I have an issue that I only have the post IDs of posts in my data repository. Since the Graph API I have to prefix the page ID before the post ID. Since I have no information what page posted this post I have a problem here.
I have my post IDs available but now need to know which post is allowed to get which post ID as prefix.
Therefore I'm looking for a way to give a post ID and receive the page ID.
Any API call that might give me that information actively or just a side-information?
I found this here:
https://graph.facebook.com/v2.8/139946919369293_811518108920728?access_token={token}&fields=from
?fields=from
does return this:
{
"from": {
"name": "Henkel Careers",
"id": "301655703240307"
},
"id": "301655703240307_811518108920728"
}
Unfortunetly that does not make any sense especially in my case. Since the Graph API does ONLY allow {page_id}_{post_id} combinations you need to actually provide the page_id in order to receive the page id by the mentioned above request.
I hope somebody has another solution!
You can try using a users access_token to get a set of page_access_tokens - then you can try mapping to the data repository and give them the option of posting to these pages using these access tokens based on the return JSON object data.
Please Note:
This is a long post.
Not sure if the title of the post is even suitable :(
Down-voters please provide some constructive feedback to improve this post before you take-off.
==========================================================
I am implementing a simple REST API in Java which exposes 3 services:
Allows clients to register their applications. POST /register
Request:
{
"display_name" : "MyAwesomeApplication"
}
Response:
{
"application_id" : "abc123def123..." ,
"application_secret" : "abc123def123..." ,
"display_name" : "MyAwesomeApplication"
}
Allows applications to authenticate before sending log messages. POST /auth
This endpoint uses a simplified version of Basic Authentication
Header
Name Value
Authorization application_id:application_secret
Response
{
"access_token" : "c47026d990bf4480a259a953bc103495"
}
Sends log messages. POST /log
Header
Name Value
Authorization access_token
Request
{
"application_id" : "abc123def123..." ,
"logger" : "com.logger.service.Uploader" ,
"level" : "Error" ,
"message" : "The communication pipeline is broken."
}
Response:
{
"success" : true|false
}
So, far I have implemented these functional requirements successfully, but I have no clue how to implement non-functional requirements like:
1. The sensitive data must be encrypted.
2. Only one active session per application(user of my web service) is allowed.
3. The session lifetime must be configurable in the database.
4. All log requests must be handled asynchronously.
5. Log endpoint requires authentication through an access token.
6. Implement a rate-limiting request to avoid possible attacks, allowing only 60 requests per minute by application. If you use up your 60 api calls then you will receive “rate limit exceeded” message and must wait 5 minutes before can make requests again.
Can someone please point me to some resources/tutorials targeted to these use cases?
I have read practically everything I could get my hands on in SO and google and the more I am reading the more I am getting confused. May be instead of trying to learn these skills in terms of REST, I should just try to implement them in a very basic client-server web app, please suggest if this should be the case.
This is my first REST web app, so please consider me a complete noob and guide accordingly.
I have been battling with this for a while and cant find a solution. I am running the SpringBoot guides and the Accessing JPA Data (http://spring.io/guides/gs/accessing-data-rest/) with REST is not working.
Just downloading it and running it runs fine allowing a GET call to
http://localhost:8080/people
using POSTMAN. However whenever I try a PUT or POST I get the following error
{
"cause": null,
"message": "No suitable HttpMessageConverter found to read request body into object of type class hello.Person from request with content type of text/plain;charset=UTF-8!"
}
The json I am passing with the PUT is
{
"firstName": "Dave",
"lastName": "Something"
}
This is just running the vanilla project with no changes. Lots of the other guide projects work fine so I know MVN, Spring boot etc are working ok.
Have tried a lot of forums but nothing suggested works.
Any help would be greatly appreciated.
Thanks
Dave
Your POST request has a content type of text/plain and the server doesn't know how to convert plain text into a hello.Person instance.
You need to tell the server that you're sending JSON by setting the Content-Type header of the request to application/json
I used Google Chrome's Postman extension and sent raw JSON { "firstName": "Frodo", "lastName": "Baggins" }. That worked.
Keep in mind to specify the HTTP header Content-Type: application/json.
Content-Type:application/json try to remove the space between content-type:* and application in the header .
Make sure you have selected the
Body->RAW->Json in the Api Client and try it worked for me.
I am not able to like a feed by a friend of the user. The unlike works if the feed has been posted by the session user. I am using the graph api endpoint /feed-id/likes. Also using the same endpoint i am able to like the feed, facing problems only for unlike. Getting the following response:
{
"error": {
"message": "(#200) Feed story publishing to other users is disabled for this application",
"type": "OAuthException",
"code": 200
}
}
The februrary breaking changes announced that only the call to [user_id]/feed where user-id is different from session user will fail.
Then why am I facing problems while trying to perform a DELETE on feed-id/likes, that too when a POST on feed-id/likes seems to work fine?
i had the same issue and solved in this way:
XXXX_YYYY is your feed-id, you can like it calling feed-id/likes using Method.POST, but for unlike you must use YYYY/likes using Method.DELETE.
PS: be sure that in your permissions you have "publish_stream".
I get
"error": {
"message": "(#100) The parameter url is required",
"type": "OAuthException",
"code": 100
}
when calling YYYY/likes using Method DELETE.