Change ContentType of a Profound API

Use this board for starting discussions, asking questions, and giving advice on Web programming for the IBM i platform (and predecessors.)
csharpest
New User
Posts: 4
Joined: Mon Feb 21, 2022 3:48 pm
First Name: Bill
Last Name: Upton
Company Name: ManhattanLife
State / Province: Texas
Country: United States
Contact:

Change ContentType of a Profound API

Post 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.
User avatar
Scot Roach
Profound Logic Staff Member
Posts: 2
Joined: Wed Jan 02, 2019 4:05 pm
First Name: Scot
Last Name: Roach
Company Name: Profound Logic Software, Inc.
Phone: 4073103816
Address 1: 3521 Fountain City Rd
City: De Soto
State / Province: Missouri
Zip / Postal Code: 63020
Country: United States
Contact:

Re: Change ContentType of a Profound API

Post 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
csharpest
New User
Posts: 4
Joined: Mon Feb 21, 2022 3:48 pm
First Name: Bill
Last Name: Upton
Company Name: ManhattanLife
State / Province: Texas
Country: United States
Contact:

Re: Change ContentType of a Profound API

Post 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...
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Change ContentType of a Profound API

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest