Title: Authentication and Create Post
Last modified: August 21, 2016

---

# Authentication and Create Post

 *  [hreynolds2](https://wordpress.org/support/users/hreynolds2/)
 * (@hreynolds2)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/authentication-and-create-post/)
 * I am trying to use this JSON-API to create a post for my wordpress site from 
   within a Ruby program.
 * However, after a get a nonce and make the post call I get this response error:
 * “error”=>”You need to login with a user that has ‘edit_posts’ capacity.”
 * How is a user supposed to “login” via a Ruby program? I am using the HTTParty
   gem for making my REST calls.
 * Here is the code I am using:
 *     ```
       nonce_response = HTTParty.get "http://example.com/?json=get_nonce&controller=posts&method=create_post"
       puts nonce_response.code
   
       nonce_info = JSON.parse(nonce_response.body)
       puts nonce_info["status"]
       puts nonce_info["nonce"]
       puts nonce_info.inspect
   
       post_body = {:nonce => nonce_info["nonce"], :status => "draft", :title => "this is only a test", :content => "great content here!",
                    :categories => "Test"}
   
       post_response = HTTParty.post( "http://example.com/?json=create_post", :body => post_body)
       ```
   
 * Thanks for any tips,
 * –harris
 * [http://wordpress.org/plugins/json-api/](http://wordpress.org/plugins/json-api/)

Viewing 1 replies (of 1 total)

 *  [atiniir](https://wordpress.org/support/users/atiniir/)
 * (@atiniir)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/authentication-and-create-post/#post-4423533)
 * Did you sort this out? i’m getting the same error

Viewing 1 replies (of 1 total)

The topic ‘Authentication and Create Post’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/json-api.svg)
 * [JSON API](https://wordpress.org/plugins/json-api/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/json-api/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/json-api/)
 * [Active Topics](https://wordpress.org/support/plugin/json-api/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/json-api/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/json-api/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [atiniir](https://wordpress.org/support/users/atiniir/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/authentication-and-create-post/#post-4423533)
 * Status: not resolved