31
Views
3
Comments
[ardoHTTP] URL Template
Question
ardohttp
Service icon
Forge asset by João Barata
Hi,

I am doing a REST integration, but for now it will have to work on platform 7. So i am using new Rest functionalities on platform 9 test it, and replicate on 7 with ardoHTTP and ardoJSON.

My question is about the bahaviour of non mandatory fields and null values.
In Version 9, i can put a input field that will go on an URL as: 'isMandatory: No ; Send Default Value: No' this means that that field will not appear on the url if it has a null value, for instance '0' for a Integer field:


I thought that URLTemplate from ardoHTTP extension could be used for this, but i don't find a way to specify that the field should not be send if it is null. Have we a way to specify this? Thanks




2014-02-13 10-06-38
Ricardo Silva
The URL Template function follows the 6570 RFC.

From what I'm reading what you want is this syntax:

https://www.example.com/foo{?query,number}

This will add query and number if they're defined. So in your case you would add the following template:

.../api/v2/{?limit,offset,sync_token,service_ids,calendar_ids,calendar_ids__or} and add the variables to the list whether or not you want them to be shown.

Please let me know if this worked for you :)
2014-02-13 10-06-38
Ricardo Silva
You can try it out here
2021-11-15 10-42-40
Mário Tomás
Thanks for the quick answer.

yes, i could work with this pattern.
I apply an url_template like: /api/v2/events/{?limit,offset,sync_token,service_ids,calendar_ids,calendar_ids__or}

and some if's validating the content of the inputs, to add or not the inputs as Variables.So for instance if limit=0, this input will not go to the list of variables, and will not be included on URL.



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.