I have…
- [x] Read the following guideline: https://docs.squidex.io/01-getting-started/installation/troubleshooting-and-support. I understand that my support request might get deleted if I do not follow the guideline.
- [x] Used code blocks with ``` to format my code examples like JSON or logs properly.
Environment
- [ ] Self hosted with docker
- [ ] Self hosted with IIS
- [ ] Self hosted with other version
- [x] Cloud version
Current behavior
I am trying to debug a script running in the creation step of a schema. The whole thing just fails around the postJSON() function. I verified every other step in the script (setting headers, creating the request body etc.) by running the script without the postJSON() call or printing the output into a field.
The whole thing just breaks on the postJSON() call. I can’t even get into the success handler. I tried just writing some static string into a field and it won’t even get into the function.
When creating an object for the corresponding schema I just get a message saying “Failed to create content. Please reload.”. The message also comes directly after trying to create the object, so it’s within the timout threshold for scripts. And I had issues with using too much compute time in the past within scripts, which resulted in an error message stating the script took to long to compute, so I suppose that also isn’t the issue.
So my issue is that I don’t get any usable feedback in order to fix whatever doesn’t work. Is there any logging capability for the script or some other way to find out, why exactly the API call doesn’t work.
I’ve verified the call itself trying it via curl and Postman. So now I’m kinda stuck.
Example
var apiUrl = "https://api.somewhere.com/v1/path"
var headers = {
Authorization: 'Bearer superSecretToken',
"Content-Type": 'application/json'
};
var requestBody = JSON.stringify({
<some valid JSON>
});
postJSON(apiUrl, requestBody, function(result) {
ctx.data.textField.iv = JSON.stringify(result);
replace();
}, headers);