Need a special offer?Find out if your project fits.
+

Datasource API

Resolved
Mario Rodrigues asked on March 21, 2020

Hi,
I'm looking to implement a custom datasource API server.  I see we can pass the URL and params and that is working fine, but there are other parameters that I'd like to pass on each request and they can change depending on user settings.  Is there a way I can set additional post params to be sent to the API server on each call?

5 answers

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster March 23, 2020

Hi Mario,
 
Thank you for writing to us.
 
You can further customize your requests using the customizeAPIRequest API call, which allows you to add additional requestHeaders to your request.
 
A detailed description of this functionality can be found by the following link: https://www.flexmonster.com/api/customizeapirequest/ 
 
Also, it might be helpful to check out our sample Node.js & .NET Core servers implementing the custom data source API for your reference. Please see them below:
Node.js server: https://www.flexmonster.com/doc/pivot-table-with-node-js-server/
.NET Core: https://www.flexmonster.com/doc/pivot-table-with-dot-net-core-server/ 
 
Please let us know if this helps.
 
Best regards,
Mykhailo

Public
Mario Rodrigues March 23, 2020

Hi, this is not working - even on the JSFiddle, the headers are not coming over:
http://jsfiddle.net/flexmonster/x6mh3c5k

Public
Mario Rodrigues March 24, 2020

I tried requestBody as well, but those params are not being passed over either.

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster March 24, 2020

Hi Mario,
 
Thank you for reporting this behavior.
 
We took a deeper look into this and realized there was indeed an issue with the JSFiddle & the provided documentation page.
 
In order for the headers to be displayed in the request, the request needs to be returned by the customizeAPIRequestFunction:
 

function customizeAPIRequestFunction(req) {
req.requestHeaders = {
"customHeader1": "This is the first custom request header",
"customHeader2": "This is the second custom request header"
};
console.log(req);
return req;
}

 
Please see the attached screenshot illustrating the results of this fix. Doing this will also fix the mentioned issue with requestBody, just as it works with the requestHeaders.
 
We've already updated the JSFiddle example correspondingly and will make sure to update the documentation as soon as possible.
 
Please let us know if you have any further questions we can help you with at the moment.
 
Best regards,
Mykhailo

Public
Mario Rodrigues March 24, 2020

Awesome!  Thank you.  It's working now.

Please login or Register to Submit Answer