airesvsg / acf-to-rest-api

Exposes Advanced Custom Fields Endpoints in the WordPress REST API
https://wordpress.org/plugins/acf-to-rest-api/
1.33k stars 111 forks source link

Can't create/update custom field value #316

Closed iMohamedSamir closed 5 years ago

iMohamedSamir commented 5 years ago

Trying to post/put custom field named sourceurl with no luck at all when I GET posts I get this: 'acf': {'sourceurl': None}, I tried to query it on http://localhost/wp-json/wp/v2/posts/1717 and the same endpoint but with v3 and application/json in the headers like this: "acf": {"sourceurl": "https://example.com'}, and this "sourceurl": "https://example.com', didn't work. I don't know if this problem with me or its an issue.

I am working with this plugins: JSON Basic Authentication Advanced Custom Fields ACF to REST API, Obviously

iMohamedSamir commented 5 years ago

@airesvsg I think its not duplicated, in https://github.com/airesvsg/acf-to-rest-api/issues/289 (Which I commented on, if this is the one you reference as a similar issue) the author was getting an error, I am not getting anything at all. I think you need to reconsider this label, and if possible to help me.

iMohamedSamir commented 5 years ago

Funny enough I found the "hacky" solution in https://github.com/airesvsg/acf-to-rest-api/issues/177 idk why it works, but it works, weirdly enough its just 1 item per request, fortunately I only have one field to post/put just found out you can post/put multiple fields per request, just add & between every fields[fieldname]=fieldvalue.

Not so helpful author tbh

For the future reader: you have to update it via url request, not in the body, don't even try, nor v2 or v3 seemed to work with us

nourseofcourse commented 5 years ago

Did you try: {"fields": {"sourceurl": "https://example.com"}

iMohamedSamir commented 5 years ago

@nourseofcourse tried it and it worked, thanks a lot