Essentially, I am wanting to pass the below request body and in cloud page, add to a data extension but unsure how I might be able to achieve this.
{
"id": "id1",
"formid" : "formid",
"data":[ {"column_name":"Full Name","string_value":"John Doe"},
{"column_name":"User Phone", "string_value":"12345678"},
{"column_name":"User Email", "string_value":"abc@123.com"}],
}
I've tested using the below and response was 200OK, just not sure what the next steps might be and seeking guidance if anyone has done something similar.
<script runat="server" language="javascript">
Platform.Load("Core","1");
var jsonpost = Platform.Request.GetPostData()
var json = Platform.Function.ParseJSON(jsonpost);
Write("<br>message: " +json.msg);
Write("<br>jsonpost: "+jsonpost);
Write("<br>json: "+json);
</script>
Updated
After running the request, the response body is as below:
<br>message: undefined
<br>jsonpost: {
"id": "id1",
"formid" : "formid",
"data":[ {"column_name":"Full Name","string_value":"John Doe"},
{"column_name":"User Phone", "string_value":"12345678"},
{"column_name":"User Email", "string_value":"abc@123.com"}],
<br>json:
msg
that contains the displayed JSON in your post? Lastly, I would also recommend writing the jsonpost and json vars as well to see where it falls over. – Gortonington Sep 10 '20 at 15:08json
is your actual object. So can use that to iterate through. E. G.var data = json.data
would pull your array out. Might need to parsejson on that as well before can use. – Gortonington Sep 10 '20 at 23:37