• Resolved hwsiew

    (@hwsiew)


    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

    (@awesomesupport)

    Hi:

    Do the users have an application ID set up in their user profile?

    Plugin Author awesomesupport

    (@awesomesupport)

    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

    Please let us know if it does.

    Thanks.

    Thread Starter hwsiew

    (@hwsiew)

    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

    (@awesomesupport)

    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

    (@hwsiew)

    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

    (@awesomesupport)

    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

    (@hwsiew)

    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

    (@awesomesupport)

    Hi:

    hmmm….are you on a multi-site version of WordPress?

    Thread Starter hwsiew

    (@hwsiew)

    No, single site wordpress.

    Plugin Author awesomesupport

    (@awesomesupport)

    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/

    Thanks.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Create Ticket API Endpoint Not Working!’ is closed to new replies.