JSON API Help Varying number of URL Parameters

JSON API Help Varying number of URL Parameters

Comments

  • Hi,

    I have a JSON API setup that allows me to create price levels in our system. We collect the data in a repeater on a form and it is setup as a SimpleDataStructure.

    When we create the item on our API there are some attributes that we need to hit. And a lot of these will vary each time we create an item so I’m not sure how to set it up.

    When we create an item, we could be setting anywhere from 0-10 Price levels

    Then within each Price level, we could be setting anywhere from 1-9 Price fields.

    So when I make the API hit to create the item I have to do it all in one go, what would be the best way to set this up?

    Thanks.

  • [color=rgb(34, 34, 34)][font=Arial, Helvetica, sans-serif]If you are expecting a varying number of URL parameters you need to do some string manipulation in the flow. Otherwise, creating a REST service and pasting your service URL will give you parameters in the created GET or POST steps. Please check below examples and if you have any questions please let me know.[/font][/color]
    [color=rgb(34, 34, 34)][font=Arial, Helvetica, sans-serif]
    [/font][/color]
    [color=rgb(34, 34, 34)][font=Arial, Helvetica, sans-serif][b]CREATING A REST SERVICE[/b][/font][/color]
    [color=rgb(34, 34, 34)][font=Arial, Helvetica, sans-serif]In order to create REST service please click to Create DataTypes/Integration button at the bottom of the designer page and select Add REST Service under the external services. [/font][/color]
    [color=rgb(34, 34, 34)][font=Arial, Helvetica, sans-serif]
    [/font][/color]
    [color=rgb(34, 34, 34)][font=Arial, Helvetica, sans-serif][img]att1[/img][/font][/color]
    [color=rgb(34, 34, 34)][font=Arial, Helvetica, sans-serif]
    [/font][/color]
    [color=rgb(34, 34, 34)][font=Arial, Helvetica, sans-serif]
    Paste your service URL to Service URL section. This will create input parameters automatically in your REST steps. In this example, I used your second service URL.

    [img]att2[/img]

    Now, you can create service methods (POST, GET etc) by using Add Method to Service button.

    [img]att3[/img]

    You can then reach created steps under Steps > Integration > REST Services.

    [img]att4[/img]

    Once you select one of these methods in your flow you should see required parameters available.

    [img]att5[/img]

    [b]STRING MANIPULATION FOR VARYING URL PARAMETERS[/b]
    In this case, you need to add a {dataToSend} parameter into the service URL. So, this will generate input for REST methods and then you should use string manipulation steps (like Join Strings, Merge to Plain String, etc) to build up a dynamic "&paramName=paramValue" string and pass it into "data To Send" input area in the REST method step.

    [img]att6[/img]

    [/font][/color]

Sign In or Register to comment.