Is it possible to have a variable in StringContent?
Currently my Code looks like this (It's about \"text\": \"this is my message\"):
myRequestMessage.Content = new StringContent("{\"type\": \"message\", \"text\": \"this is my message\", \"from\": {\"id\": \"myID\", \"name\": \"myName\"}}", System.Text.Encoding.UTF8, "application/json");
But I want to have it like this (\"text\": "+myOwnString+"):
myOwnString = "this is my text";
myRequestMessage.Content = new StringContent("{\"type\": \"message\", \"text\": "+myOwnString+", \"from\": {\"id\": \"myID\", \"name\": \"myName\"}}", System.Text.Encoding.UTF8, "application/json");
My problem is when doing it like I want to have it I get a StatusCode 400, ReasonPhrase: Bad Request from var myResponse = await myClient.SendAsync(myRequestMessage);. So I assume I have to write it differently to make it work.
Does anyone know a fix?
\"text\": \"" + myOwnString + "\"