Post to an external service with an array

Post to an external service with an array

Comments

  • Hi,

    I’m trying to post to a rest API using the following data structure. Note that the markets object is an array:

    {

    "Done": {
    
        "UserDetails": {
    
            "ID": {ID},
    
            "Role": {Role},
    
            "AgencyName": {AgencyName},
    
            "UserType": {UserType},
    
            "UserName": {UserName}
    
        },
    
        "markets": [
    
            {
    
                "ID": {marketID},
    
                "state": {state},
    
                "geography": {Geography},
    
                "UserName": {UserName},
    
                "subbrand": {subbrand},
    
                "channel": {channel},
    
                "brand": {brand}
    
            }
    
                ]
    
    }
    

    }

    However, when the post is sent, for some reason the markets array is being sent as part of the main object itself instead of an array and it only sends the first array object. See below from the debugger:

    [img]att1[/img]

    This is despite the data being configured as an array as shown below:

    [img]att2[/img]

    This is happening because when I configure the object in the flow I don’t get the option to specify that part of the object is an array. See screenshot below:

    [img]att3[/img]

    Can you please advise on the best approach to resolve this?

    Thanks

  • Hi,

    Are you defining that JSON sample at the beginning of your email statically on the REST service step/integration? If yes, you will need to create a datatype from this JSON, then use a JSON serialize step and pass the serialized string into this step. The text merge editor does not read the array chars and automatically gives you an array input mapping.

    Your new input format would be something like {dataToSend} on the step/integration. And you would pass the entire serialized string into this input.

    Regards

  • Oren, are you from israel? Gimme a call mkartoon@elta.co.il

Sign In or Register to comment.