Title: Create Ticket API Endpoint Not Working!
Last modified: March 22, 2018

---

# Create Ticket API Endpoint Not Working!

 *  Resolved [hwsiew](https://wordpress.org/support/users/hwsiew/)
 * (@hwsiew)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/create-ticket-api-endpoint-not-working/)
 * Hi, I am trying to create a ticket grammatically using the AS API plugin. I created
   an API password for an admin user who has the right to create ticket using admin
   panel. However, I couldn’t create ticket using basic authentication via API endpoint(
   POST wpas-api/v1/tickets) . It showed an error message as follow.
 *     ```
       {
       "code": "rest_cannot_create",
       "message": "Sorry, you are not allowed to create tickets as this user.",
       "data": {
       "status": 401
       }
       }
       ```
   
 * Instead, I tried to use the original wp password of the admin user and it work
   via the API endpoint. So, i guess it has nothing to do with the user capabilities.
 * Any idea what could result in my case?
 * Thank for your advice.

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Plugin Author [awesomesupport](https://wordpress.org/support/users/awesomesupport/)
 * (@awesomesupport)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/create-ticket-api-endpoint-not-working/#post-10105249)
 * Hi:
 * Do the users have an application ID set up in their user profile?
 *  Plugin Author [awesomesupport](https://wordpress.org/support/users/awesomesupport/)
 * (@awesomesupport)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/create-ticket-api-endpoint-not-working/#post-10105512)
 * Also, here’s the snippet of code that will return that error message – maybe 
   it’ll point you to something in your configuration:
 * [⌊03.22.2018-16.40.36⌉⌊03.22.2018-16.40.36⌉[
 * Please let us know if it does.
 * Thanks.
 *  Thread Starter [hwsiew](https://wordpress.org/support/users/hwsiew/)
 * (@hwsiew)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/create-ticket-api-endpoint-not-working/#post-10105841)
 * HI, application ID do you mean the API password in the user profile. if Yes, 
   then yup i have set it up for basic authentication.
 * I see you highlighted the error message in the picture, and i think my error 
   message is the second ‘if’ clause instead of the first one. The error code of
   my error is “rest_cannot_create”. If not mistaken, the second ‘if’ clause check
   for the user capabilities to create ticket. The admin user has this capability
   granted and has been verified by creating a ticket at admin panel & use the original
   wp password via API endpoint.
 *  Plugin Author [awesomesupport](https://wordpress.org/support/users/awesomesupport/)
 * (@awesomesupport)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/create-ticket-api-endpoint-not-working/#post-10105852)
 * I would edit the REST API code to add some debuggging code in there (error_log
   type function calls) to see who the logged in user is when that error is being
   thrown. Its possible that the logged in user is not who you think it is when 
   that error is being thrown.
 * The rest api code file is called ticketbase.php – just search in it for the error
   messsage and you’ll end up in the codeblock where you should add the debug code.
 * Thanks.
 *  Thread Starter [hwsiew](https://wordpress.org/support/users/hwsiew/)
 * (@hwsiew)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/create-ticket-api-endpoint-not-working/#post-10105872)
 * Thank you for the prompt reply.
 * I tested it out as you suggested. I tried to get user id in between the ‘if’ 
   clause but it return id 0. Any idea what could be a reason for that?
 * Thanks
 *  Plugin Author [awesomesupport](https://wordpress.org/support/users/awesomesupport/)
 * (@awesomesupport)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/create-ticket-api-endpoint-not-working/#post-10105876)
 * Hi:
 * It looks like the authentication is failing somewhere but isn’t being reported
   back to you as a failure for some reason. Zero is not a valid user id so the 
   user isn’t logged in.
 * You’re probably going to want to follow that authentication nibble down the rabbit
   hole and see where its failing in the process.
 * Or you could double-check the authentication configuration you’re using – it 
   could be something there as well.
 * Thanks.
 *  Thread Starter [hwsiew](https://wordpress.org/support/users/hwsiew/)
 * (@hwsiew)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/create-ticket-api-endpoint-not-working/#post-10105902)
 * Hi, i followed the trail in /Auth/User.php ‘authenticate’ function. I see my 
   password is correct in the function. However, there is one thing i noticed, the‘
   $hashed_passwords’ is empty. I have the API password setup in user profile. Does
   this ‘$hashed_passwords’ suppose to be empty?
 * Thanks
 *  Plugin Author [awesomesupport](https://wordpress.org/support/users/awesomesupport/)
 * (@awesomesupport)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/create-ticket-api-endpoint-not-working/#post-10105932)
 * Hi:
 * hmmm….are you on a multi-site version of WordPress?
 *  Thread Starter [hwsiew](https://wordpress.org/support/users/hwsiew/)
 * (@hwsiew)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/create-ticket-api-endpoint-not-working/#post-10105950)
 * No, single site wordpress.
 *  Plugin Author [awesomesupport](https://wordpress.org/support/users/awesomesupport/)
 * (@awesomesupport)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/create-ticket-api-endpoint-not-working/#post-10108519)
 * Ok. Lets try something different. Lets see if we can eliminate code related issues.
   Can you follow this tutorial with your installation and see if it works: [https://getawesomesupport.com/tutorial-create-tickets-using-data-pushed-zapier/](https://getawesomesupport.com/tutorial-create-tickets-using-data-pushed-zapier/)
 * Thanks.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Create Ticket API Endpoint Not Working!’ is closed to new replies.

 * ![](https://ps.w.org/awesome-support/assets/icon-256x256.png?rev=1849681)
 * [Awesome Support - WordPress HelpDesk & Support Plugin](https://wordpress.org/plugins/awesome-support/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/awesome-support/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/awesome-support/)
 * [Active Topics](https://wordpress.org/support/plugin/awesome-support/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/awesome-support/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/awesome-support/reviews/)

 * 10 replies
 * 2 participants
 * Last reply from: [awesomesupport](https://wordpress.org/support/users/awesomesupport/)
 * Last activity: [8 years, 2 months ago](https://wordpress.org/support/topic/create-ticket-api-endpoint-not-working/#post-10108519)
 * Status: resolved