-2

I am trying to set a content type of this:

System.FormatException: 'The format of value 'multipart/form-data;boundary=ce4da8a9-0e0d-4ba6-9f00-e7f3b002a717' is invalid.'

when executing this

HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri)
{
    Content = new StringContent(postData, Encoding.UTF8, content_type) // CONTENT-TYPE header
};

but according to this

https://learn.microsoft.com/en-us/skype-sdk/ucwa/batchingrequests https://ucwa.skype.com/documentation/Resources-batch-3 https://ucwa.skype.com/documentation/ProgrammingConcepts-Batch

All the resources say to use the format that I have. And it doesn't complain about this in Postman too. Is there a way I can force this content type in the StringContent in c#?

There is an answer here

How do I send arbitrary JSON data, with a custom header, to a REST server?

but I'm not sure how to implement this.

maccettura
  • 10,514
  • 3
  • 28
  • 35
omega
  • 40,311
  • 81
  • 251
  • 474
  • I tried putting the answer from the link, but it says `__DynamicallyInvokable` is not defined. – omega Aug 15 '18 at 19:53

1 Answers1

0

The answer s/b somewhat obvious from the error message. "multipart/form-data;boundary=ce4da8a9-0e0d-4ba6-9f00-e7f3b002a717" is not a valid content type. Even if you were creating a custom content type, you are prohibited from using the following characters:

( ) @ < > , ; : \ " / [ ] ? = { }

The presence of any of these in your content type will cause

StringContent(postData, Encoding.UTF8, content_type)

to fail with a System.FormatException

kooch
  • 107
  • 1
  • 5
  • 1
    How can I attach this custom content type then? If I can send this in postman, there should be a way in c#? – omega Aug 15 '18 at 20:07
  • I don’t believe the boundary info should be part of the content type. – kooch Aug 18 '18 at 22:07