Skip to content

Cannot Create Post. #8

Open
Open

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.

Activity

  1. pimedia commented on Feb 7, 2018

    @pimedia
    Owner
  2. raffaelecolleo commented on Feb 7, 2018

    @raffaelecolleo
    Author

    With JSON API User Plus is a Subscriber allowed to create posts?

  3. pimedia commented on Feb 7, 2018

    @pimedia
    Owner
  4. emmjk commented on Apr 9, 2018

    @emmjk

    even though i'v loged in i still get the same results as the one mentioned above , The bad thing is if i try to write a post request from a browser it works fine but the same request doesnt work if requested from a postman with result from postman being the same as mentioned above and the result from a browser being status ok and post id and some other parameter . I think you need not to run away from this one bro , you need to fix this .

  5. emmjk commented on Apr 9, 2018

    @emmjk

    Also something just came through my mind , To get as error that says "Your 'nonce' value was incorrect. Use the 'get_nonce' API method." is actually because the nonce is verified to not being valid as per source code available (Nonce is verified with wp_verify_nonce() function ) So how can you say its a log in issue even though the error is due to nonce verification failure that has appeared for a logged in user like me as explained above . I strongly think your argument of loged in user is of important but it is the case that will happen if the user did not provide authentication cookie from his request to create a post to a wordpress site . But if authentication cookie is given as one of the parameter as shown above by raffaelcolleo it crashes the loged in user issue and the main thing should be nonce verification "if statement) . Please try to go through your code to verify about that .

  6. pimedia commented on Apr 10, 2018

    @pimedia
    Owner
  7. emmjk commented on Apr 12, 2018

    @emmjk

    Oky , I went through your website to get the JSON Api plus plugin , It seems your plugin allows even non registered users to be able to write a post to my wordpress site . But what i want is a plugin that allows only registerd and loged in user to write a post on a wordpress based site but from an android application am making . Do you have any recommendations for that ?

  8. raffaelecolleo commented on Apr 26, 2018

    @raffaelecolleo
    Author

    Ok. I bought 6 days ago the Single License. Sent emails to m [dot] ali [dot] qureshi [at] gmail [dot] com and no reply.

    I need to know where I can download the plugin.

    Any Ideas?
    Thanks

  9. pimedia commented on Apr 26, 2018

    @pimedia
    Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions