[ardoHTTP] URL Template

[ardoHTTP] URL Template

  
Forge Component
(15)
Published on 2015-06-04 by Ricardo Silva
15 votes
Published on 2015-06-04 by Ricardo Silva
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




The URL Template function follows the 6570 RFC.

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

http://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 :)
You can try it out here
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.