Nils_Schmidt | 2020-07-06 11:19:34 UTC | #1
Hi there,
I am trying to create a new row in a datatable with an .Net Programm, but i do not choose the right data type for the datatable object. I tried a list of KeyValuePair and Serialize this to JSON, but i get alway an error back.
Here is my code so far:
var architectApi = new ArchitectApi(); var eintrag = new List<KeyValuePair<string, string>>() { new KeyValuePair<string, string>("Telefonnummer", TelefonnummerValue), new KeyValuePair<string, string>("KEY", KeyValue), new KeyValuePair<string, string>("Name", NameValue) }; var jsonEintrag = JsonConvert.SerializeObject(eintrag); architectApi.PostFlowsDatatableRows( tableID, jsonEintrag);
Every Time I get a 400 Error Message due to wrong format.
Maybe one of you can help me. Thanks a lot!
Nils
anon11147534 | 2020-07-06 13:11:40 UTC | #2
Hi Nils,
Your code produces the following output from JsonConvert.SerializeObject (I added the value names as strings for brevity):
[{"Key":"Telefonnummer","Value":"TelefonnummerValue"},{"Key":"KEY","Value":"KeyValue"},{"Key":"Name","Value":"NameValue"}]
Try using the following code to produce output in the format that the server expects:
...
Dictionary<string, string> eintrag = new Dictionary<string, string>
{
{ "Telefonnummer", TelefonnummerValue },
{ "KEY", KeyValue },
{ "Name", NameValue }
};
...
That code will output:
{"Telefonnummer":"TelefonnummerValue","KEY":"KeyValue","Name":"NameValue"}
Hope this helps.
Ronan
Nils_Schmidt | 2020-07-06 13:45:06 UTC | #3
Hi Ronan,
It works! Thank you so much!
Kind Regards, Nils
system | 2020-08-06 13:45:07 UTC | #4
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 8200