Help with variables within body of POST Http Request

I am trying to populate a body for a POST, but can’t seem to figure out how to use variables within. I have successfully gotten the POST to work with a static body from a text file, but I want to use variables as it is a dynamic request. Here is what my body looks like where the CaseID and name would be a variables:
{
“taskId”: 1234,
“data”: [
{
“index”: 0,
“columnName”: “System”,
“value”: “TEST”
},
{
“index”: 1,
“columnName”: “CaseId”,
“value”: “ABC123”
},
{
“index”: 2,
“columnName”: “Name”,
“value”: “Smith, John”
}
],
“documentItemGuid”: null
}

Hi @Cox_Cameron_M_TS_CI3129_I

Please refer below post. Basically idea is to double the double quotes to be able to pass variables, should look like below where userid is a variable and name has static value.

jsonBody = “{”“id”“: “”” + userID + “”“, ““name””: ““John””}”

@Cox_Cameron_M_TS_CI3129_I

simple and direct way would be to use place holders intext and then use replace function

{
“taskId”: 1234,
“data”: [
{
“index”: 0,
“columnName”: “System”,
“value”: “TEST”
},
{
“index”: 1,
“columnName”: “CaseId”,
“value”: “<CASEID>”
},
{
“index”: 2,
“columnName”: “Name”,
“value”: “<NAME>”
}
],
“documentItemGuid”: null
}

say the above is assigned to str string variable

str.Replace("<CASEID>",actualcasedID).Replace("<NAME>",actualname)

cheers

Thanks! I realized I was using only 2 quotes instead of 3 between the variables and that’s what was failing.

1 Like

@Cox_Cameron_M_TS_CI3129_I

I am glad it worked :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.