Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

UpdateData mapping Json api

Answered
Henrique Nunes asked on October 6, 2020

Hi.
 
I’m using a JSON data source api, but I didn’t understand how I can use the updateData API call for a JSON data source.
 
My data source object looks like this and it’s working:

dataSource:{
"dataSourceType": "json",
"filename": "https://.../api/v1.0/dataSource",
"mapping": "https://.../api/v1.0/mapping"
}

 
And what I’m trying to do is something like this:

flexmonster.updateData({
"dataSourceType": "json",
"filename": "https://.../api/v1.0/dataSource",
"mapping": "https://.../api/v1.0/mapping"
});

I’ve changed the mapping URL to a JSON and it worked, but I want to know how to pass the JSON through my endpoint without having to hardcode it.
 
Best regards,
Henrique.

3 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster October 7, 2020

Hello, Henrique,
 
Thank you for reaching out to us.
 
We want to explain that if the file’s URL does not differ from the currently used one, Flexmonster will ignore the request. It is done to omit to reload the same data.
 
To force the reloading, add an additional unique parameter to the URL:

flexmonster.updateData({
  "type": "json",
  "filename": `https://cdn.flexmonster.com/data/data.json?${new Date().getTime()}`,
  "mapping": "https://www.flexmonster.com/fm_uploads/2020/10/mapping.json"
/*In its turn, the mapping object will be reloaded regardless of whether
it is the same as the previous one or not.*/ });

In this example, we complement the URL with a current timestamp. Every timestamp differs from the previous one and forces Flexmonster to reload the data.
 
You are welcome to see the example we have prepared for you. Use the “Network” tab of your browser developer tools to trace requests made by the component. Every time the “Update Data” button is pressed, both the mapping object and the data set are loaded.
 
If you still having issues, please send us an example where the problem would be reproducible.
 
Please let us know if it works for you.
Do not hesitate to contact us in case further questions arise.
 
Kind regards,
Illia

Public
Henrique Nunes October 8, 2020

It worked!
 
Thank you very much.
 
Best regards,
Henrique.

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster October 8, 2020

Hello, Henrique,

Thank you for your feedback.
Our team is happy to hear everything works for you.

You are welcome to contact us in case any other questions arise.

Kind regards,
Illia

Please login or Register to Submit Answer