Page 1 of 1
Change ContentType of a Profound API
Posted: Tue Feb 22, 2022 10:52 am
by csharpest
How can I change the content type that an endpoint will accept in ProfoundAPI? I have a node module that will decode multipart/form-data that is working well when I add a custom route in start.js. But this is not working for me using low-code apis built in the IDE. From the IDE's tester which uses content-type: application/json it does not get the error below.
However when I use Postman to pass the actual parms + file using the multipart/form-data header I get this specific error...
Code: Select all
{"error":{"message":"c:\\Projects\\TestProjects\\ProfoundJSDEV\\modules\\my_module\\uploader.api.json is not callable."}}
The low-code API approach is preferred because all of the advantages that come with it: parameter definitions, testing, etc...
Thanks for any ideas you may have.
Re: Change ContentType of a Profound API
Posted: Wed Feb 23, 2022 7:26 pm
by Scot Roach
When you get this error. Have you removed that express route from the start.js and restart your server.
The Profound API (low-code) does not need this registration.
Could you share part of your code from the that uploader.api.json.
At present, Profound API only supports the content type of application/json. I will bring this up to the development team to consideration.
Thank,
Scot
Re: Change ContentType of a Profound API
Posted: Mon Feb 28, 2022 9:42 am
by csharpest
I used different endpoints for the 2 tests. My LowCode uses "uploadTEST". And the one I put in start.js is just "upload".
Adding this to start.js works:
Code: Select all
app.all("/upload/", profound.express(__dirname + "\\modules\\webdocs_DEV\\uploader.js"));
In the lowCode version my first step is Custom Node.js Code and it looks like this:
Code: Select all
function webdocsApiUpload(request, response) {
console.log('inside Custom Node.js Code')
var mgr = pjs.require('uploader.js')
mgr.uploader(request, response)
}
module.exports.run = webdocsApiUpload(request, response);
Since Profound UI has that upload capability I thought it would work with API. Thanks though...
Re: Change ContentType of a Profound API
Posted: Mon Feb 28, 2022 8:09 pm
by Scott Klement
You're correct that Profound UI (and Profound.js) Rich Display screens have a file upload widget. This is something you drag onto a screen in order to facilitate uploads to the application that's driving that screen.
Since you are using an API, there's no screen, and no widgets that can be enabled -- so that wouldn't apply, here.
As Scot said, we'd be happy to create a feature request for adding file uploads to Profound.js for things like APIs (or to Profound API, which you mention in the title of the thread, but your code samples appear to be for Profound.js).
If you're interested in a feature request, please reach out to
support@profoundlogic.com