I am currently working on a custom application that using a button click fires off a post request for ticket creation in freshservice but I am running into a 500 error with a response of “We’re sorry but something went wrong”.
Tested ticket creation using postman and it worked without issue.
Here is the code snippet that I am using for the post request.
In the screenshot that I attached to this you can see that I incorporated the Authorization in the headers. I’m not sure if you were indicating that it was incorrect or if you noticed something else wrong with the code snippet. Appreciate you taking a look at this. I did try removing “encode” and the parenthesis around iparam.freshservice_api_key as you mentioned but got the same error when attempting the post request.
Wow you were right after I sent the last message I took a closer look at my code and I did in fact type out the line of code for the authorization incorrectly. I was missing the “%” in the first iparam tag. Silly mistake but thank you for making me double check!!!
This worked correctly after fixing that mistyped error.
I have ran into another issue regarding this custom app.
It appears that after making the above mentioned changes, it would allow the post request to be made successfully. After validating the app and packaging it to install, I installed the application in my sandbox environment. Now I am back to getting a 500 error.
If I run the application locally and use ?dev=true on a ticket, then execute the application it functions just fine. Is anyone aware of limitations to app behavior when installed through the developer portal in a freshservice sandbox environment?
Since this app needs to be throughly tested before installing into my production environment I was hoping to be able to see it function as intended in our sandbox environment beforehand.
In this screen shot you can see the application installed (top), and it also installed locally using the fdk test environment (bottom). Successful using locally ran app (first group of console logs), fails using installed application (last group of console logs).
I would really like to test the installation and use in the sandbox before installing our production environment as to minimize the risk of agents using the application inadvertently prior to its full release.
That was my understanding as well. I took the working code that was fixed by your first suggestion. All tags, <%= %>, are correct. I then validated the application, packaged the application, and installed the application in the sandbox as a custom app through the developer portal. Once the app became available I installed it into the sandbox environment entering the correct freshservice sub-domain and API key for my sandbox environment as instructed by the installation parameters that I designed. The code runs and works until the POST request where it fails and I get the 500 Error that you see in the above screenshot. So I am not sure what is causing the issue.
We can validate that the code is correct because when I run “fdk run” and append ?dev=true to a ticket in the sandbox, the code runs and the post request is successful using the exact same code that was packaged for the app.
Removing the space did in fact fix the issue. Could you elaborate as to why this simple type error would allow the application to run locally without issue but prevent it from working when packaged and installed?
Appreciate your advice and help in solving this issue.
The application functions, the post request is successful and creates a ticket that I can see inside the freshservice sandbox. I can share with you the debug logs if that helps but there is sensitive information (sub-domain, api keys) that I would like to not expose.