(PUT) endpoint not working as expected for Tick entries - api

Using the PUT request to update Tick entries is not working as expected. Using the following: PUT /entries/235.json will update the entry from the parameters passed
GitHub link: https://github.com/tick/tick-api/blob/master/sections/entries.md#update-entry
Currently receiving a 400 Bad Request (screenshot)
I tried the GET request to confirm authorization is working as expected, and received a 200

Related

Shares endpoint on LinkedIn API not working

The endpoint to get shares by owner is not working for me.
This is the full URL I'm using:
https://api.linkedin.com/v2/shares?q=owners&owners=urn:li:organization:{ID}
But I receive this error:
{"serviceErrorCode":0,"message":"Invalid query parameters passed to request","status":400}
I know the access token I'm using is working, if I try to get one share by ID the response is a success, using the following URL:
https://api.linkedin.com/v2/shares/urn%3Ali%3Ashare%3A{ID}
Am I doing something wrong? For me this error looks like a bug in the API

How to call API with AntiForgeryToken using Postman in IdentityServer ASP.NET Core

I'm trying to test my API with Identity Server Asp.net Core using Postman.
This is the way that I'm trying to do:
First request HttpGet to https://localhost:5000/Account/Login and in response body I received: <input name="__RequestVerificationToken" type="hidden" value="CfDJ8MoS9upoM4dNp8Kx-AdvA-uYr13_PAkuMZpzYMV8UmxZq5GdLTvN-Ht5NpTLmPtlhL5d5z2Hu2vUJoJGhk1AMlARDcOwqgq7Cef1dfQL_vl4tIFM4kx9RZPz8DHU26-U9qLnKAIstZgR42-1FuGNh24" />
And in Cookie (not sure for what it is though):
Then HttpPost to https://localhost:5000/Account/Login with RequestVerificationToken with token received from body HttpGet request.
And always error 400 as you can see at screen shot above.
In Visual studio I can see that some request was catched but clearly was incorrect.
If I'll remove attribute [ValidateAntiForgeryToken] then of course everything works fine but obviously because that validation is disabled.
You'd need to do followings to send such a request:
1.) Enter __RequestVerificationToken key value (don't forget double underscores) into x-www-form-urlencoded
2.) You need to add .AspNetCore.Antiforgery cookie to the Cookies section in Postman.
For example like this
.AspNetCore.Antiforgery.1XHiLFgQI2w=your cookie value; Path=/; Domain=localhost;Expires=Session;
You can find .AspNetCore.Antiforgery cookie in Application section in Google Developer Tools
.AspNetCore.Antiforgery cookie in Google Developer Tools picture
Add cookie in Postman picture
Just spent a lot of time on this.
I did several things:
Setup an Environment and added a variable.
Added a pre-request script that...
Uses pm.SendRequest to Get the page
uses cheerio to find the first input field named __RequestVerificationToken and get its value
set the environmental variable to the value retrieved from the field
send the form data (since I'm using asp.net core, the values for the model), as x-www-form-urlencoded
and last, but not least, I added __RequestVerificationToken as one of the key value pairs in the form data and set it to the use the variable already setup
The main reason I am posting this answer is the last, I saw a lot of things on the web that indicated that name was supposed to be RequestVerificationToken, and that doesn't work, just leads to a 400 response (bad request).
In postman, you’d need to set the content type to form url encoded.
And send the request Verification token in the header as "RequestVerificationToken"
However, if you just need a Bearer token then you need to call
POST https://<your identity server>/connect/token with the

Update issue fields in JIRA

Hi I am using postman client for Chrome to run my rest api calls. I am trying to update issue in JIRA via rest API. I have referred to JIRA API also for updating an issue.
I am using PUT method to update an issue fields. Here is the syntax.
PUT /rest/api/2/issue/{issueIdOrKey}
I am trying to update summary field like this.
{"update":{"summary":[{"set":"Bug in business logic"}]}}
But it is giving me the 400 bad request error.
and in the body its showing message "No content to map to Object due to end of input".
Please find the attached screenshot for more reference. Thanks in Advance.Jira Update issue
In postman rest API client, add the json object to Body as in the below picture.
I added authorization as Basic Authorization and provided JIRA credentials.
Note that the body should be raw and type should be JSON(application/json) instead of Text(default).
Response for this PUT request is 204 when update is successful.
Here is REST API Documentation for additional options.

How to check if entity is inside a list with RESTful APIs?

I am designing the APIs for the backend of my app.
Suppose the user can follow the activity of another user.
In this case, I designed an API which allow me to do:
POST /me/following
and the id as body for this request.
Then I can retrieve the list of followers in this way:
GET /me/following
This API comes with pagination, so I cannot retrieve the entire list at once.
But how can I check if the user follows another user? Should I use something like
GET /me/following/{user_id}
and check the status code for this request? Like 200 it exists or 404 it doesn't exists in the list?
Usually 404 means the endpoint called doesn't exists. What if the entity doesn't exists? Is there a status code for that?
GET /me/following/{user_id} seems good.
I would probably return a 204 No Content :
Successful 2xx
This class of status code indicates that the client's request was successfully received, understood, and accepted.
[...]
204 No Content
The server has fulfilled the request but does not need to return an
entity-body, and might want to return updated metainformation.
404 in contrast describes some kind of error, though it could do the job as well depending how you look at it
Client Error 4xx
The 4xx class of status code is intended for cases in which the client
seems to have erred.
404 Not Found
The server has not found anything matching the Request-URI. No
indication is given of whether the condition is temporary or
permanent.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

"missing required parameters, includes an invalid parameter value..." when POSTing accessToken request on linkedin API

I am following authentication doc for fetching the user profile details after authentication on linkedin.
I have successfully completed the first step to GET the authorization_code. But when i do a POST in the second step using same authorization_code and redirect_uri as the previous request, i get following response:
{"error_description":"missing required parameters, includes an invalid parameter value, parameter more than once. : client_id","error":"invalid_request"}
I have checked the parameters to POST request multiple number of times and don't find anything wrong there e.g. using the correct authorization_code and redirect_uri.
Also read some of the answers to similar issue, most of them say that authorization_code expires in less than 10 or 20 seconds. But in my case, POST request uses the authorization_code within 1 second of receiving it in Step 1. So, expiration should not be a problem here.
I am using Rails 3.0.7 and Net::HTTP to send the POST request. I have tried adding parameters to the URL as well as to request's body. Neither of them worked.
Any help would be appreciated.
Thanks in advance.