I am writing a post process event script using the Dreamfactory ‘Scripts’ interface and would like to get additional data using the platform.api object.
Due to the potentially long number of IDs in my filter, I am attempting to get the data by POST. The only part I can’t figure out is how to set the X-HTTP-METHOD header to GET. I’ve come up with the following code based on the wiki: https://github.com/dreamfactorysoftware/dsp-core/wiki/API-Access-via-Scripts
if (event.response.record) {
var options = {
"CURLOPT_HTTPHEADER": ["Content-type: application/json", "X-HTTP-Method: GET"]
};
result = platform.api.post(
"db/example_table",
{"filter": "id IN (321,322,323)"},
options
);
var_dump(result); // No valid fields were found in record.
}
But I get “No valid fields were found in record.” Everything works if I use platform.api.get instead of POST.
I originally thought I needed this approach because I ran into an error with the URL being too long when I was passing a really long string of IDs as a URL parameter to the API from my app. Because this is server-side it might not have the same length limitation. I’m not sure how the arguments are passed through, but things have been working fine just using GET.