I want to add tracking information for PayPal transactions and use examples from docs:
curl -v -X PUT https://api-m.sandbox.paypal.com/v1/shipping/trackers/8MC585209K746392H-443844607820 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <my access token>" \
-d '{
"transaction_id": "8MC585209K746392H",
"tracking_number": "443844607820",
"status": "SHIPPED",
"carrier": "FEDEX"
}
But the response is:
{"errors":[{"name":"INVALID_TRANSACTION_ID","message":"Invalid data provided","debug_id":"4bec***8348","details":[{"field":"#/transaction_id","value":"8MC585209K746392H","location":"body","issue":"INVALID_TRANSACTION_ID"}]}]}
Where is my mistake?
It would seem that is not a payment transaction ID from a capture. Perhaps you are mistakenly passing an Order ID -- which is only used during approval and not persisted nor useful after capture.
The PayPal transaction ID is in the capture response at purchase_units[0].payments.captures[0].id
Related
I want to create TeamCity users with various roles through the API. As long as I provide no role, I know how to do it, like so:
curl -X POST http://localhost:8111/app/rest/users \
-H "Content-Type: application/json" \
-d '{"username":"user", "password":"password"}' \
-u :<super-user-token>
Now, my issue is that e.g. I want to create an administrator. I tried this:
curl -X POST http://localhost:8111/app/rest/users \
-H "Content-Type: application/json" \
-d '{"username":"user", "password":"password", "roles": {"role": [{"roleId": "PROJECT_ADMIN"}]}}' \
-u :<super-user-token>
The roleId is a value that comes from the roles-config.xml file in folder <TeamCity Data Directory>/config, should be fine. I get the following error:
Responding with error, status code: 400 (Bad Request).
Details: jetbrains.buildServer.server.rest.errors.PartialUpdateError: Partial error updating user 'zadigus' {id=3}, nested errors: jetbrains.buildServer.server.rest.errors.PartialUpdat
eError: Partial error updating roles for user 'zadigus' {id=3}, nested errors: java.lang.IllegalArgumentException: Argument for #NotNull parameter 'scopeData' of jetbrains/buildServer/
server/rest/model/user/RoleAssignment.getScope must not be null
There was an error processing the request, but the data could be updated partially. Please ensure consistent data state.
because I provide no scope. I was not able to find any information about what values I can feed the scope field with. Where are they documented?
I am using TeamCity version 2022.04.4.
I found it. In order to get the possible values for the scope field, just run
curl -X POST http://localhost:8111/app/rest/users \
-H "Content-Type: application/json" \
-d '{"username":"user", "password":"password", "roles": {"role": [{"roleId": "PROJECT_ADMIN", "scope": "invalid-value"}]}}' \
-u :<super-user-token>
In the reply to this request, we get the information that possible values are either g or p:<projectId>.
I already successfully scheduled a lot of jobs using the REST API of the Azure IoT-Hub as described in https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-jobs. Namely I scheduled jobs to execute direct methods.
But, when I try to query the status of the scheduled jobs (as described on the same page), I always get only one entry: the status of the first successfully scheduled job. How do I get the status of all jobs?
My query was:
curl -X GET \
https://<iot-hub-name>.azure-devices.net/jobs/v2/query?api-version=2018-06-30 \
-H 'Authorization: SharedAccessSignature <sas-token>' \
-H 'Content-Type: application/json; charset=utf-8' -o response.json
The SAS Token I used above was the same as for scheduling the job. Thus, there is no authentication issue.
The formatted response just contains 1 entry despite that I already scheduled 11 jobs:
[
{
"jobId": "job02",
"queryCondition": "deviceId = simple_thermostat",
"createdTime": "2022-03-02T15:59:27.4093129Z",
"startTime": "2022-03-02T15:20:15Z",
"endTime": "2022-03-02T15:59:34.5969497Z",
"maxExecutionTimeInSeconds": 10000,
"type": "scheduleDeviceMethod",
"cloudToDeviceMethod": {
"methodName": "getMaxMinReport",
"payload": "hello",
"responseTimeoutInSeconds": 300,
"connectTimeoutInSeconds": 0
},
"status": "completed",
"deviceJobStatistics": {
"deviceCount": 0,
"failedCount": 0,
"succeededCount": 0,
"runningCount": 0,
"pendingCount": 0
}
}
]
PS: Getting the status of a single job works as expected. Like using this request:
curl -X GET \
https://<iot-hub-name>.azure-devices.net/jobs/v2/job11?api-version=2018-06-30 \
-H 'Authorization: SharedAccessSignature <sas-token>' \
-H 'Content-Type: application/json; charset=utf-8' -o response.json
But, job11 is never returned in the query above.
As pointed out by Roman Kiss, the continuation token can be found in the header of the first response. To save the header via curl one must specify the option -D. So, the first query must look like:
curl -X GET \
https://<iot-hub-name>.azure-devices.net/jobs/v2/query?api-version=2018-06-30 \
-H 'Authorization: SharedAccessSignature <sas-token>' \
-H 'Content-Type: application/json; charset=utf-8' \
-D response_hdr.txt -o response.json
Then response_hdr.txt will contain a line like this:
x-ms-continuation: eyJzb3VyY2UiOiJkZGIiLCJ0b3RhbFJldHJpZXZlZENvdW50Ijo4LCJjb250aW51YXRpb25Ub2tlbiI6Ilt7XCJ0b2tlblwiOm51bGwsXCJyYW5nZVwiOntcIm1pblwiOlwiMDVDMUU3RkZGRkZGRkFcIixcIm1heFwiOlwiRkZcIn19XSJ9
But, this continuation token must not be specified in the URL as stated in the Microsoft docs. Instead it must be provided in the header of the subsequent query:
curl -X GET \
https://<iot-hub-name>.azure-devices.net/jobs/v2/query?api-version=2018-06-30 \
-H 'Authorization: SharedAccessSignature <sas-token>' \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'x-ms-continuation: <continuation_token_from_previous_query>' \
-D response_hdr.txt -o response.json
This query will deliver a new continuation token. It looks pretty similar, but it is not identical.
I can register events with USER.SUBMIT_FORM_DATA no problem, also I can Update (PUT) all the other event filters without errors. USER.SUBMIT_FORM_DATA fails when using PUT to update. Reproduced error in PowerShell, Curl and Postman. I also noticed Swagger does not have USER.SUBMIT_FORM_DATA available in the array. This is what's available:
CONVERSATION.CREATE
CONVERSATION.UPDATE
CONVERSATION.ADD_ITEM
CONVERSATION.UPDATE_ITEM
USER.USER_UPDATED
USER.USER_SETTING_UPDATED
Request:
curl -L -X PUT 'https://circuitsandbox.net/rest/v2/webhooks/IdHere' \
-H 'accept: application/json' \
-H 'authorization: Bearer Token\
-H 'content-type: application/x-www-form-urlencoded' \
--data-urlencode 'url=https://webhook.site/IdHere' \
--data-urlencode 'filter=USER.SUBMIT_FORM_DATA'
Error:
{
"errorDescription": "the request contains invalid data",
"validationErrors": [
"The request array with name ::= [filter] and content value ::=[USER.SUBMIT_FORM_DATA]does not match the expression ::= [CONVERSATION.CREATE||CONVERSATION.UPDATE||CONVERSATION.ADD_ITEM||CONVERSATION.UPDATE_ITEM||USER.USER_UPDATED||USER.USER_SETTING_UPDATED]."
],
"errorCode": "400"
}
Sorry, that is a bug in the endpoint, I added a fix which will be available with the next release.
I want to construct a curl command using Gitlab's API so that I can edit a README.md file. I know it is possible according to docs:
https://docs.gitlab.com/ee/api/repository_files.html
I am able to find my project with curl 'https://private.private.io/api/v4/56/projects?private_token=private-token'but I can't seem to go any deeper in order to read or edit a file in repo.
UPDATE
The solution is
curl --request PUT --header 'PRIVATE-TOKEN: private-token' --header "Content-Type: application/json" --data '{"branch": "master", "author_email": "email", "author_name": "name",
"content": "status, building", "commit_message": "update file"}' 'https://private.private.io/api/v4/projects/56/repository/files/README.md'
Please consider using this solution mentioned in the docs here.THis allows you to update a single file
curl --request PUT --header 'PRIVATE-TOKEN: <your_access_token>' --header "Content-Type: application/json" \
--data '{"branch": "master", "author_email": "author#example.com", "author_name": "Firstname Lastname", \
"content": "some content", "commit_message": "update file"}' \
'https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fproject%2Erb'
i'll try to get data by following API calling:
Uber API -- POST /requests/estimate
curl -X POST \
-H 'Authorization: Bearer JA.VUNmGAAAAAAAEgASAAAABwAIAAwAAAAAAAAAEgAAAAAAAAG8AAAAFAAAAAAADgAQAAQAAAAIAAwAAAAOAAAAkAAAABwAAAAEAAAAEAAAAHK_p1D73ZBrTyH5MuBCGAhsAAAA28z3l42QLSOiQE_6m1J30O4ZQjwpDR_rVf5o41ONOluUZohTYhXEhHNBCLkDO0mXJV39hE2RkcsIRm9ICi_UMVGESeHsQ_uRsX_yD1EDoUbcdHa0Yhf8XGOJkFz1-IB5x9Ivq6SxHpmREeExDAAAAGRcztTG8GDUTlDYpSQAAABiMGQ4NTgwMy0zOGEwLTQyYjMtODA2ZS03YTRjZjhlMTk2ZWU' \
-H 'Accept-Language: en_US' \
-H 'Content-Type: application/json' \
-d '{
"start_latitude": 37.7752278,
"start_longitude": -122.4197513,
"end_latitude": 37.7773228,
"end_longitude": -122.4272052
}' "https://api.uber.com/v1.2/requests/estimate?scope=request
Response
{"code":"unauthorized","message":"This endpoint requires at least one of the following scopes: profile, request, request.delegate, request.delegate.tos_accept, surge_accept"}%
While Below API are working Fine
/products
/estimates/price
/estimates/time
this is old API. New one looks like this.
GET /v1.2/estimates/price