I am trying to update a custom field via the WordPress API. The custom field is within an Advanced Custom Fields repeating layout and I cannot figure out how to update it.
I have authentication set up and can update a post status, but I'm not having any luck in updating the ACF data.
Using Postman : Page status can be updated with http://localhost:9000/wp-json/wp/v2/pages/4564/?status=public. Is there a similar value which can be used to update the ACF field or a way to update by passing JSON instead?
{
"id": 4564,
...
"acf": {
"insert_to_head": "",
"insert_to_foot": "",
"Layout": [
{
"acf_fc_layout": "cert_challenge_pin",
"challenge_pin": "0527881"
}]
}
The ACF to REST API plugin is in use and fields can be viewed via the API but not updated.
Having exhausted search and documentation, any help would be greatly appreciated!
I found from this post that you should use the key fields instead of acf. In addition, I had to send a Content-type: application/json header to get it working.
Related
I'm trying to use the Twitter API in Google Script to get the non-public metrics of my posts.
I believe have done all of the authentication properly since I am able to get the information when using Postman. I have generate a consumer_key, a consumer_secret, an access_token, and a token_secret.
According to the twitter documentation , I MUST use Oauth1.0 (https://developer.twitter.com/en/docs/twitter-api/metrics).
In order use the Oauth1, I used Google's own script for Twitter Oauth1 (https://developers.google.com/google-ads/scripts/docs/examples/twitter-oauth10).
I was able to take that code (along with the library it required) and successfully retrieve the tweets for my username.
My attempt to get the non_public metric was replacing the "https://api.twitter.com/1.1/statuses/user_timeline.json" with the GET request I had from POSTMAN but it returned a "401 error".
I have a hunch that I can't just replace that url with my own but I am unsure how to approach it.
In summary:
Tokens/Twitter Authorization/GET request are written properly since they work in Postman
Google Script is writing properly since the default URL works
Unsure how to replace the default url to accomplish different tasks
Ended up figuring it it out!
I was not supposed to pass the entire url as a replacement for "https://api.twitter.com/1.1/statuses/user_timeline.json".
It is supposed to be replaced by the "base" url. In my case this was "https://api.twitter.com/2/tweets".
I then had to change the variable "params" that feed into it.
note that the params is from the code provided by Google in my original post
They have to be in the following format (https://developer.twitter.com/en/docs/tutorials/twitter-api-google-sheets):
params = {
"tweet.fields": "author_id,created_at,lang",
"ids": "21,1293593516040269825,1334542969530183683",
}
I was able to add my own fields such as "non_public_metrics,organic_metrics" to get:
params = {
"tweet.fields": "author_id,created_at,lang,non_public_metrics,organic_metrics",
"ids": "21,1293593516040269825,1334542969530183683",
}
I hope this helps someone someday :)
I am using IFTTT.com and on their webhooks page it says
With an optional JSON body of:
{ "value1" : "", "value2" : "", "value3" : "" }
This works fine when I use curl.. however, for my application I can only call a single url. Does anyone know if this is possible in the format like;
https://maker.ifttt.com/trigger/<keyword>/with/key/<key>/value1=blah&value2=blah
I hope this helps.
I wanted to send 3 values via a single url and this is what worked for me.
https://maker.ifttt.com/trigger/My_web_hook/with/key/My_Key?value1=11&value2=13&value3=17
Post JSON data to IFTTT in single url
I hope this helps.
I wanted to send 3 values via a single url and this is what worked for me.
https://maker.ifttt.com/trigger/My_web_hook/with/key/My_Key?value1=11&value2=13&value3=17
My key was followed by a "?", (you have a "/") and then the values. The data 11,13,17 was received by my "webhook" and passed onto me in an email. This is what I wanted to happen.
This perhaps?
https://maker.ifttt.com/trigger//with/key/?value1=blah&value2=blah
I found help in another page here on Stack Overflow but unable to upvote yet. Look for "How to pass data to IFTTT WebHook?"
I'm using the Plugin JSON API and i can't post nothing on "custom_fields".
On Postman (what i'm using to test) no matter what i put on value (i have tryied form-data and raw) but i can't post anything.
It stay on "custom_fields": {}
Could someone help me to understand what a specific example of an API link would look like for the following API?
https://engradesandbox.com/docs/
They show examples in the documentation about what the JSON result/return of an API, but not an actual example of what a call would look like.
I've noticed this with most API's, they show the possible result data, but not the default url syntax. It's so frustrating, because looking through existing restful tutorials isn't very fruitful on the subject either.
How do you know what the actual API call should look like?
That actually does tell you you what to do.
All "calls" will be HTTP POST to the URL specified.
If you click on one of them, it takes you to a page that explains the input data for that method.
For example, see the class-behavior-add function. To call that function, you'd post to the URL they specify (https://api.engradesandbox.com/ as of this posting), and the content of your post would be XML or JSON that contains the fields specified here.
Example post data as JSON:
{
"apitask": "class-behavior-add",
"apikey": "your_api_key",
"ses": "session token id",
"clid": 1234567890,
"stuid": "student ID",
"date": 123456789,
"mark": 12,
"points": 123
}
Example post data as XML:
<engrade>
<apitask>class-behavior-add</apitask>
<apikey>your_api_key</apikey>
<ses>session token id</ses>
<clid>1234567890</clid>
<stuid>student ID</stuid>
<date>123456789</date>
<mark>12</mark>
<points>123</points>
</engrade>
The example on the Brightcove site provides the JSON needed to update tags for a particular video in my library:
{"method":"update_video","params":{"video":{"id":"123456",
"shortDescription":"vidDesc","Name":"vidName","startDate":1392912992000,
"endDate":null,"tags":["tag1","tag2","tag3"]},"token":"someToken.."}}
I've tried this, and it works.
But when I try to post something similar but with an updated reference ID, like this:
{"method":"update_video","params":{"video":{"id":"123456",
"shortDescription":"vidDesc","Name":"vidName","startDate":1392912992000,
"endDate":null,"referenceId":"newReferenceId","token":"someToken.."}}
I get this error back from the service:
{"error": {"name":"MissingJSONError","message":"Could not find JSON-RPC.",
"code":211}, "result": null, "id": null}
I've tried passing it as ref as well - no dice. Does anyone know if it's possible to update this value via any means other than Brightcove's web portal?
Make sure you're sending the JSON as form data rather than in the post body.
e.g. with curl,
curl -F 'json={"method":"update_video","params":{"video":{"id":"123456789","referenceId":"newrefid"},"token":"myToken"}}' https://api.brightcove.com/services/post