I'm trying to update a WooCommerce order using Update an Order in the Woo API (API Doc)
I want to add the following information into an order:
tracking provider
tracking number
tracking URL
I can add/update information inside of the "meta data" array, however, I can't seem to figure out how to update the "_wc_shipment_tracking_items" "value" array that is located within the "meta data" array.
So essentially, I want to update/create an array within an array. For a visual understanding, see (highlighted is where I want to update):
I’ve tried many variations, but the following is as far as I've come... I can’t seem to figure it out:
"meta_data": [
{
"key": "_wc_shipment_tracking_items"
"value": [
{
"key": "custom_tracking_provider",
"value": "postage service"
},
{
"key": "tracking_number",
"value": "aaa123"
},
{
"key": "custom_tracking_link",
"value": "https://google.com/"
}
]
}
]
I hope someone can help me out, or point me in the right direction. Thank you :)
The answer to your question can be found on this page:
https://woocommerce.com/document/shipment-tracking/
under 'REST API Support' you will find this piece of code that you need:
curl -X POST https://example.com/wp-json/wc-shipment-tracking/v3/orders/645/shipment-trackings \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"custom_tracking_provider": "Custom",
"custom_tracking_link": "https://example.com?q=%1$s",
"tracking_number": "12345678"
}'
Related
I want to get all the results from a full text search index in couchbase. However, the default limit is 10 results.
I am aware that I can customize the size to a specific number, but is it possible to set it such that I get all the results in one go?
Something like "size":"*" or "size":"all"
curl -u user:password -X POST -H "Content-Type: application/json" \
-d '{"query": {"query": "search_token"}, "size": 10}' \
http://1.2.3.4:8094/api/index/myindex/query
It doesn't look like there's an "all" option for size. Omitting size falls back to 10.
I tried using a really large number, and got an error message:
{
"error": "rest_index: Query, indexName: ix_myindex, err: bleve: bleveMaxResultWindow exceeded, from: 0, size: 999999999, bleveMaxResultWindow: 10000",
"request": {
"query": {
"query": "search_token"
},
"size": 999999999
},
"status": "fail"
}
So, 10000 is the max you can ask for by default.
According to Couchbase ticket MB-17539, you can increase the maximum:
curl -XPUT -H "Content-type:application/json" http://<username>:<password>#<ip>:8094/api/managerOptions -d '{"bleveMaxResultWindow": "100000"}'
I tried this, and it works. However, I don't see this endpoint in the documentation so it might change/become deprecated in the future.
But, I really have to wonder why you need this many results at once? Is paging not an option for you? (e.g. a body of {"query": {"query": "search_token"}, "size": 10, "from": 10}).
I don't know much about how to use an API, and I am just trying to get a basic understanding so I can use the Timekit.io API in a JS app I am going to build, so to start I though I should try and use postman to learn how to send a request. In the Timekit documentation for finding a time from a resource ie: a persons calendar they say to use this curl command.
curl --request POST \
--url https://api.timekit.io/v2/findtime \
--header 'Content-Type: application/json' \
--user :live_api_key_7nzvc7wsBQQISLeFSVhROys9V1bUJ1z7 \
--data '{
"resource_ids": ["78a4d873-2a68-41c6-bdd4-c0ca5b35efd3"],
"filters": { "or": [
{"specific_day_and_time":{"day":"Monday","start":9,"end":13}},
{"specific_day_and_time":{"day":"Wednesday","start":10,"end": 16}}
]},
"future": "2 days",
"length": "30 minutes"
}'
I am trying to figure out what I put into postman itself so I get the correct Json values. So far I have selected a POST request with the url https://api.timekit.io/v2/findtime and a header with the key Content-Type and value application/json I have no idea where to put the user,data,rsource_ids,filters,future & length Here is a screenshot of my post man setup.
--user sets the authentication. If an authentication type is not specified, then it will default to Basic Authentication. In Postman, click the "Authentication" tab and from the "Type" dropdown, select "Basic Auth". You can then input the username and password into the appropriate fields. With the --user flag, the value should be <username>:<password>. So your case, there is no username specified, so I guess you don't need to input it, just use the api key for the password.
--data is the JSON request body. You can input this entire value (within the single quotes ') into the "Body" tab. Select the "Body" tab, and within the tab, select the "raw" radio button, and from the dropdown to the right, select "JSON (application/json)". Now just put the entire JSON into the text area.
{
"resource_ids": ["78a4d873-2a68-41c6-bdd4-c0ca5b35efd3"],
"filters": {
"or": [
{ "specific_day_and_time":{ "day":"Monday", "start":9, "end":13 } },
{ "specific_day_and_time":{ "day":"Wednesday", "start":10, "end": 16 } }
]
},
"future": "2 days",
"length": "30 minutes"
}
You could just drop the curl request straight into Postman via the Import feature, this would populate the whole request in the application for you.
In the top left of the application UI, select the Import button and then select the 'raw' text option (it’s the last one) - paste the curl request text into the text box. Once imported, that should do the rest for you, if it’s a valid format.
Whenever I log on the azure web portal i get a notification saying $xx.xx remaining credit.
I would like to understand how I can retrieve this value using Azure API, az cli or Powershell.
I have tried using the following as advised by the support but unfortunately without luck:
accesstoken=$(curl -s --header "accept: application/json" --request POST "https://login.windows.net/$TennantID/oauth2/token" --data-urlencode "resource=https://management.core.windows.net/" --data-urlencode "client_id=$ClientID" --data-urlencode "grant_type=client_credentials" --data-urlencode "client_secret=$ClientSecret" | jq -r '.access_token')
subscriptionURI="https://management.azure.com/subscriptions/$SubscriptionID?api-version=2016-09-01"
curl -s --header "authorization: Bearer $accesstoken" --request GET $subscriptionURI | jq .
The spending limit variable says just "on"
{
"authorizationSource": "RoleBased",
"subscriptionPolicies": {
"spendingLimit": "On",
redacted (too long)
When you see "$xx credit remaining", it means your account has spending limit. There are many offerings which use spending limit mode. For example, you are given Azure Pass, or Microsoft Azure for Students Starter. Here is the list for reference (https://azure.microsoft.com/en-us/support/legal/offer-details/).
In fact, Azure provides some REST APIs to let you work with Billing and Consumption but the API is limited to spending limit offerings. Advanced billing and consumption REST API are only fully supported for CSP (Cloud Service Provider) partner and Enterprise Agreement customers. That's said, with your current subscription, you cannot retrieve the balance summary (e.g https://learn.microsoft.com/en-us/rest/api/billing/enterprise/billing-enterprise-api-balance-summary).
However, there is a workaround to get usage details then perform SUM. To do so, first you need to retrieve billing period name
https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods?api-version=2017-04-24-preview
Here is the sample response of my billing periods:
"value": [
{
"id": "/subscriptions/2dd8cb59-ed12-4755-a2bc-356c212fbafc/providers/Microsoft.Billing/billingPeriods/201805-1",
"type": "Microsoft.Billing/billingPeriods",
"name": "201805-1",
"properties": {
"billingPeriodStartDate": "2018-02-06",
"billingPeriodEndDate": "2018-03-05"
}
},
{
"id": "/subscriptions/2dd8cb59-ed12-4755-a2bc-356c212fbafc/providers/Microsoft.Billing/billingPeriods/201804-1",
"type": "Microsoft.Billing/billingPeriods",
"name": "201804-1",
"properties": {
"billingPeriodStartDate": "2018-01-06",
"billingPeriodEndDate": "2018-02-05"
}
},
...then get usage detail with the billing period name
https://management.azure.com/subscriptions/{Subscription}/providers/Microsoft.Billing/billingPeriods/201805-1?api-version=2017-04-24-preview
{
"id": "subscriptions/2dd8cb59-ed12-4755-a2bc-356c212fbafc/providers/Microsoft.Billing/billingPeriods/201805-1/providers/Microsoft.Consumption/usageDetails/cdd74390-374b-53cf-2260-fc8ef10a2be6",
"name": "cdd74390-374b-53cf-2260-fc8ef10a2be6",
"type": "Microsoft.Consumption/usageDetails",
"tags": null,
"properties": {
"billingPeriodId": "subscriptions/2dd8cb59-ed12-4755-a2bc-356c212fbafc/providers/Microsoft.Billing/billingPeriods/201805-1",
"usageStart": "2018-02-06T00:00:00Z",
"usageEnd": "2018-02-07T00:00:00Z",
"instanceId": "/subscriptions/2dd8cb59-ed12-4755-a2bc-356c212fbafc/resourceGroups/securitydata/providers/Microsoft.Storage/storageAccounts/2d1993southeastasia",
"instanceName": "2d1993southeastasia",
"meterId": "c1635534-1c1d-4fc4-b090-88fc2672ef87",
"usageQuantity": 0.002976,
"pretaxCost": 7.1424E-05,
"currency": "USD",
"isEstimated": false,
"subscriptionGuid": "2dd8cb59-ed12-4755-a2bc-356c212fbafc",
"meterDetails": null
}
},
This returns list of each resource's usage and cost in JSON format and you need to SUM all pretaxCost value. This way would be complicated with PowerShell because you need to initialize objects, then deserialize JSON and perform MATH. With PowerShell, it can be done technically but requires C# experience.
Github issues may contain "reactions" for quite a while (as described here: https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments)
I would like to receive that information using the Github api, but there doesn't seem to be anything like that when getting an issue e.g.
api.github.com/repos/twbs/bootstrap/issues/19575
that information does not seem to be inside that response. Also, I did not find another API call that could retrieve that information. How to get those "reactions"?
This is now possible, being the preview state (meaning, you have to pass a custom Accept header in the request). Check out the GitHub API documentation page
Example
$ curl -H 'Accept: application/vnd.github.squirrel-girl-preview' https://api.github.com/repos/twbs/bootstrap/issues/19575/reactions
[
{
"id": 257024,
"user_id": 947110,
"content": "+1"
},
...
{
"id": 888868,
"user_id": 1889800,
"content": "+1"
}
]
The endpoint looks like this:
GET /repos/:owner/:repo/issues/:number/reactions
You can even pass a content parameter (querystring) indicating what kind of reaction you want to retrieve.
I'm able to send push notifications to mobile clients that subscribe to channels (let's say channel_1 and channel_2 using Parse REST API by POSTing a JSON to https://api.parse.com/1/push:
{
"channels": ["channel_1", "channel2"],
"data": { "alert": "Test" }
}
However, I'd like to send the notifications to people who subscribe to channel_1 and channel_2 but also don't subscribe to another specific channel (channel_3).
Is there a way to do that with Parse REST API? I know I can do that via Parse's admin panel.
I think advanced targeting is a better fit for what you're trying to achieve
https://parse.com/docs/push_guide#sending-channels/REST
It is easier to understand the concept looking at the Javascript documentation and then replicate for REST.
I posted my question on Parse forum, and someone from Parse responded:
In this case, you'll want to use Advanced Targeting. Basically, construct a query over the Installation class that targets objects subscribed to both channels, and don't have the third in the "channels" key.
curl -X POST \
-H "X-Parse-Application-Id: YOUR_APP_ID" \
-H "X-Parse-REST-API-Key: YOUR_REST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"where": {
"channels": {"$all": ["channel_1", "channel_2"], "$nin": ["channel_3"]}
},
"data": {
"alert": "Hello world!"
}
}' \
https://api.parse.com/1/push