OData 404 or 403 on patch - odata

When I updated OData to v4 my patch operations started returning 403 and 404 errors.
My url was in the format
curl -X PATCH "http://portal-service/odata/Downloads/553"

The problem was that I was not using the correct odata format for patch.
curl -X PATCH "http://portal-service/odata/Downloads(553)"

Related

msgraph teams api, filter for groups only with teams

I have a requirement to filter for teams which have a given string. To achieve that I found the following documentation https://learn.microsoft.com/en-us/graph/teams-list-all-teams. I cannot use the beta APIs, so the only option left for me as per this is to
Get all the teams using /groups?$select=id,resourceProvisioningOptions
Manually do the filtering
I am a bit worried that this could overload the server since I am loading a lot of data and then filtering, is there a better way to do this?
Also I tried the following curl command curl -H "Accept: application/json" -H "Authorization: Bearer token" -X GET "https://graph.microsoft.com/v1.0/groups?$select=id,resourceProvisioningOptions" -k but this returns all the fields like expirationDateTime, displayName and so on. Am I doing something wrong in this curl command
Please check below curl command
curl --location --request GET 'https://graph.microsoft.com/v1.0/groups?$select=id,resourceProvisioningOptions,displayName&$filter=startswith(displayName,%27abc%27)' \
--header 'Authorization: Bearer token'

what is the REST API query for http://review.xx.yy.com/gerrit/#/c/240262/

Can some one explain what is the exact query for the below in GERRIT REST API to get all the information
http://review.xx.yy.com/gerrit/#/c/2401262/
Execute the following command to get all information about 2401262 change:
curl --user USER:PASS --request GET http://review.xx.yy.com/a/changes/2401262

Convert curl request to Rails Net::HTTP

An API I am using is telling me to make a GET request as follows:
curl -s \
-X GET \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3/REST/template/$template_ID/detailcontent
and I am trying to convert this to Rails' NET::HTTP. I've tried adding a req.body, adding ?user=TOKEN and keep getting a 401 Unauthorized response. I've tested it in curl and my credentials are valid.
How do I include the --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" portion in my GET request?
--user in curl is used for server authentication. In your case, after --user you provide username and password separated with colon. This will be used for the http basic authentication.
Since you know that, you can check how to do the basic authentication with NET::HTTP here or here.

Uploading file to rest API using JMeter

Note - I have checked BlazeMeter Tutorial which uploads doc as Body Data while I use File Upload tab.
Here is how my request looks -
On execution I get following Request -
POST https://xxx
POST data:
<actual file content, not shown here>
[no cookies]
Request Headers:
Connection: keep-alive
Content-Type: multipart/form-data
Accept-Language: en-US
Authorization: bearer <>
Accept: application/json
Content-Length: 78920
Host: test-host
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_102)
And the request fails with 400 error -
Response code: 400
Response message: Bad Request
Since I am able to carry out file upload using curl, I assume that I missed the some configuration with JMeter. Curl looks as -
curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' --header 'Authorization: Bearer <>' -F upload_file=#"test.pdf" 'https://xxx'
What did I miss in JMeter file upload?
Another vote for using the Java implementation in the Advanced tab in Jmeter. My headers and body were exactly the same between postman and jmeter, but it wouldn't upload my file (got response code 415) until I changed to the Java implementation.
If you can successfully upload file via curl, why don't you just record the upload through JMeter HTTP(S) Test Script Recorder like:
curl -x http://localhost:8888 -X POST --header 'Content-Type....."
If you still need to build the request manually consider two important bits:
You need to check Use multipart/form-data for POST.
The most significant, you need to supply "Parameter Name", According to HTTP Request Sampler Manual:
For the POST and PUT method, if there is no file to send, and the name(s) of the parameter(s) are omitted, then the body is created by concatenating all the value(s) of the parameters.
Looking into curl command manual in your case the "Parameter Name" should be upload_file
So the final configuration should look like:
See Performance Testing: Upload and Download Scenarios with Apache JMeter guide for above steps described in details.
My backend server is implemented in Java and in the file upload request I had to select the Impolementation as Java!
Here is the file upload section
thank you for the JAVA implementation of HTTP! file uploads are working again for me which haven't worked since 2.13
here's my post else where:
I had same issue...thought jmeter was doing something wrong since this stuff worked for me in 2.13...hasn't worked since version 3. well..saw a post somewhere that said, using the JAVA implementation of HTTP worked. Guess what? it did work for me too!!! I've been struggling trying to dissect every part of the POST. I was doing it right all along, just needed JAVA implementation of HTTP and voila!
hope that helps!

restify example TODO server not sending responses

I'm new at this and developing my first API server. I wanted to see an example of a POST request so I installed restify 3.0.3 and tried to run the TODO server example. I see the requests logged at the server but no response is sent. I'm using the sample curl requests provided and the server is running on Cloud9. Curl is running on windows 7.
For example, I've tried:
curl -isS http://test-atk9.c9.io | json
curl -isS http://test-atk9.c9.io/todo -X POST -d name=demo -d
task="buy milk"
Can anyone help?
I saw the same behavior when using PostMan to exercise the example.
Setting the PostMan Header Accept:text/plain or Accept:application/json worked for me.
BTW: if you set Accept:text/html, you should receive a helpful response:
{
"code": "NotAcceptableError",
"message": "Server accepts: application/todo,application/json,text/plain,application/octet-stream,application/javascript"
}
Hope this helps.

Resources