How to use C# keyword inside a object as key of a field?

48 views Asked by At

I think I have a very unique problem here.

I am using a message service to send WhatsApp messages to our opted-in users.

The vendor's API to send message has the following body structure:

'template={"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","params": []}'

The problem is, whenever I try make call to this API from C# (a dotnet core project), I get error because params is a keyword in c#.

So when I try the following the code, it throws error that it is a keyword.

keyValues.Add(new KeyValuePair<string, string>("template", JsonConvert.SerializeObject(new { id = templateId, params = [] })));

How to survive this deadly problem?

0

There are 0 answers