![]() Thanks to Dr Deo in the comments.įor the record, I laughed with giddy joy when I finally figured this one out. Make sure the file type is one of the accepted file types and you're including the extension of the file is included in the request. At least, this is the case until they change it all around. All you have to do to successfully submit your new content is add the following to your header: 'Content-Disposition' => 'filename=name-of-file.jpg',Īs mentioned in the ticket, you cannot add quotes or specify the method you're using to send the file. You have to specify the filename of the media file to associate to your new content. As you can see from the v2 documentation, source_url and link are read-only. You have to specify the filename of the media file to associate to your new content. You can do this by using the methods registerpostmeta link (a convenience wrapper for registermeta link useful for custom post types) or you can use registermeta directly. This endpoint is creating the media content in the database that references this file. First, you need to register the meta key in the REST API before the REST API can handle that meta data for the post/custom post. The API assumes at this point you have already uploaded a new file to the correct directory. The Purpose of Create Media Endpointįirst, Let's take a step back. Act as a social media content writer, analyze this outline outline, and remove/add parts if necessary to make the blog post more engaging and informative. This is a required header for posting new media content and there are some very, very strict requirements when it comes to providing this in the proper format. I found an issue reported on the WP-API issue queue about Content-Disposition. Keep in mind the WP-API is still very, very much a work-in-progress. $data = $client->fetch("wordpress.local/wp-json/wp/v2/media", $values, "POST") $client->setAccessTokenType(OAuth2\Client::ACCESS_TOKEN_BEARER) $response = $client->getAccessToken(TOKEN_ENDPOINT, 'authorization_code', $params) //authorization_code $params = array('code' => $_GET, 'redirect_uri' => REDIRECT_URI) This allows WC data to be created, read, updated, and deleted using requests in JSON. $auth_url = $client->getAuthenticationUrl(AUTHORIZATION_ENDPOINT, REDIRECT_URI) WooCommerce (WC) 2.6 is fully integrated with the WordPress REST API. ![]() $client = new OAuth2\Client(CLIENT_ID, CLIENT_SECRET) Require('OAuth2/GrantType/AuthorizationCode.php') Require('OAuth2/GrantType/IGrantType.php') Take a look at the example below https://example. Method 2: Add embed at the end of the URL. I did not find in the REST API documentation the way to send my image data (name of field, sending mode.?). I dont recommend to use this plugin unless you are super lazy. I need your help to upload a media image in my wordpress blog via the Wp-rest-api v2 and Oauth2 authentication. Extension for the wordpress REST-API to update, add and change images in the WP Media-Library - GitHub - MartinvonBerg/ExtRESTMediaLib: Extension for the. ![]()
0 Comments
Leave a Reply. |