We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
please. I have an 401 (Unauthorized) error when I create a post
error: https://localhost/hl-bir/wp-json/wp/v2/posts 401 (Unauthorized)
and this is the function:
createPost(body: any) { let headers = new Headers(); headers.append('Content-Type', 'application/json;charset=UTF-8'); headers.append('Access-Control-Allow-Origin', '*'); headers.append('Access-Control-Allow-Headers', 'Content-Type, Content-Range, Content-Disposition, Content-Description'); headers.append('Access-Control-Allow-Methods', 'DELETE, HEAD, GET, OPTIONS, POST, PUT'); headers.append('Authorization', 'Basic ' + btoa('username:password')); headers.append('Cache-Control', 'no-cache'); this.wpApiPosts.create(body, headers) .toPromise() .then(response => response.json()) .then(res => { console.log(res); }) .catch(err => { console.log(err); }); }
this.wpProvider.createPost( { titte: 'MyPost3', status: 'publish' } );
Note that there is no problem in creating a new post from the URL in the chrome browser using the plugin JSON API https://localhost/hl-bir/api/create_post/?nonce=5bee184120&title=mypost4&status=publish
Thanks in advance
The text was updated successfully, but these errors were encountered:
No branches or pull requests
please.
I have an 401 (Unauthorized) error when I create a post
error: https://localhost/hl-bir/wp-json/wp/v2/posts 401 (Unauthorized)
and this is the function:
createPost(body: any) {
let headers = new Headers();
headers.append('Content-Type', 'application/json;charset=UTF-8');
headers.append('Access-Control-Allow-Origin', '*');
headers.append('Access-Control-Allow-Headers', 'Content-Type, Content-Range, Content-Disposition, Content-Description');
headers.append('Access-Control-Allow-Methods', 'DELETE, HEAD, GET, OPTIONS, POST, PUT');
headers.append('Authorization', 'Basic ' + btoa('username:password'));
headers.append('Cache-Control', 'no-cache');
this.wpApiPosts.create(body, headers)
.toPromise()
.then(response => response.json())
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});
}
Note that there is no problem in creating a new post from the URL in the chrome browser using the plugin JSON API
https://localhost/hl-bir/api/create_post/?nonce=5bee184120&title=mypost4&status=publish
Thanks in advance
The text was updated successfully, but these errors were encountered: