I need to post an object in this format:
POST https://link
{
  "country": "nld",
  "emailaddress": "email@domain.com",
  "phone": "123",
  "notify_url": "https://asd.com"
}
I tried:
 var url = "URL";
            var httpRequest = (HttpWebRequest)WebRequest.Create(url);
            httpRequest.Accept = "*/*";
            httpRequest.Headers["Authorization"] = "Bearer " + apiKey;
            var postData = "country" + Uri.EscapeDataString("hello");
            postData += "emailaddress" + Uri.EscapeDataString("world");
            postData += "phone" + Uri.EscapeDataString("123");
            postData += "notify_url" + Uri.EscapeDataString("d3wq");
            var data = Encoding.ASCII.GetBytes(postData);
            httpRequest.Method = "POST";
            httpRequest.ContentType = "application/x-www-form-urlencoded";
            httpRequest.ContentLength = data.Length;
            using (var stream = httpRequest.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }
 
            HttpWebResponse httpResponse = null;
            try
            {
                httpResponse = (HttpWebResponse)httpRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();
                }
            }
            catch (Exception e) { }
But the server returns a 400 bad request. I think the data is in invalid format.
How can i alter my code to put the data into correct format ?
Thank you!
 
     
    