Thanx Alex,
I checked all the resource and I am able to call rest api from service script but rest api is not working from pre and post script. I don’t know if anybody else has reported this issue.
When we see this, it’s usually because there was an error during the script writing process. Have you pasted your script in a code editor to check?
Our built in code editor has BASIC syntax checking. But that would only alert you if you don’t close the line or try use a deprecated function, for example. Therefore, a more robust IDE would be ideal for troubleshooting the things that are not DreamFactory specific.
Hi all, I’m experiencing similar problem, whenever I call “platform.api.get” DF always returned HTTP 500.
I added below code to one of my API (using method PATCH) pre-processing script:
if (event.request.payload.myfield) {
var result = platform.api.get("/user/session");
console.log(result);
}
which doesn’t really ring a bell, end up in frustration, I copy “node -e '…(_wrapperResult));” and run in shell, and this is the error returned
callback(body, response);
^
TypeError: undefined is not a function
at IncomingMessage. (eval:106:21)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:448:13)
Not sure if it’s missing nodejs packages, I went to node_module directory and installed callback and bunch of other packages, still getting HTTP 50 whenever platform.api.get is called.
Here’s my setup
CentOS 7 x64
Apache 2.4.6
DreamFactory 2.2.1, installed from github
service access: service “all”, component “*”, access all 5, requester “api, script” (I know it’s bad, will change accordingly after I solve this weird question)
If any of you experienced/solved similar problem, please do share the solution, thanks in advance.
(Sorry to hijack your thread, I tried to create a new topic but I kept getting 500 Internal server error.)
I’m glad to see that you figured it out, @lewis! Thanks for posting your answer.
Would you be able to elaborate on this comment? We always appreciate the opportunity to make our documentation better. The more specific you can get, the better.