Skip to content

Cannot Create Post. #8

@raffaelecolleo

Description

@raffaelecolleo

Hi there,
I am trying to create a post using jSON Api and jSON Api User.
My username is administrator so should be ok and Password does not have & or # in it.

Here's what I am doing:

var nonce = jQuery.getJSON( "https://www.example.com/api/get_nonce?json=get_nonce&controller=posts&method=create_post" );
console.log(nonce);
// ATTENTION: cookie was created on a login page and stored at localStorage.
var dataString = "controller=posts&method=create_post&cookie=" + localStorage.getItem("cookie") + "&nonce=" + nonce.responseJSON.nonce + "&post_type=my-custom-type&title=Post Created by APP";
console.log(dataString);
jQuery.ajax({
type: "GET",
url:"https://www.example.com/api/posts/create_post?",
data: dataString,
crossDomain: true,
cache: false,
success: function(data){
console.log(JSON.stringify(data));
},
error: function(data){
console.log(JSON.stringify(data));
}
});

I am getting back this error:
{"readyState":4,"responseText":"{\"status\":\"error\",\"error\":\"Your 'nonce' value was incorrect. Use the 'get_nonce' API method.\"}","responseJSON":{"status":"error","error":"Your 'nonce' value was incorrect. Use the 'get_nonce' API method."},"status":403,"statusText":"Forbidden"}

Any Ideas on how to solve this?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions