Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set Content-Type request header #16

Open
ccarmannt opened this issue Nov 13, 2019 · 2 comments
Open

Unable to set Content-Type request header #16

ccarmannt opened this issue Nov 13, 2019 · 2 comments

Comments

@ccarmannt
Copy link

I need to set the Content-Type header on a request:

        request.WithHeaders(new { Content_Type = "text/plain" });

But the call above results in the following exception:

System.InvalidOperationException : Misused header name. Make sure request headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent objects.
   at System.Net.Http.Headers.HttpHeaders.CheckHeaderName(String name)
   at System.Net.Http.Headers.HttpHeaders.Add(String name, String value)
   at James.Testing.Rest.HttpClientExtensions.AddHeaders(HttpClient client, Object headers)
   at James.Testing.Rest.RequestBase`2.Execute()
   at James.Testing.Rest.Request.Execute[TResponse,TError](IRequest`2 request)
   at James.Testing.Rest.Request.Post[TBody,TResponse,TError](TBody body)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   at James.Testing.Rest.Request.Post(Object body)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)

I've attempted to find another method within the James.Testing.Rest package that can be used for this, but without success...

@toddmeinershagen
Copy link
Owner

So - the library currently makes an assumption that posts are going to use the "application/json" content type.

Would you send me an example of the what is being passed in the Post(object body) method call and what you expect to come back in the body?

@ccarmannt
Copy link
Author

I don't know yet exactly what is going to be passed in the body. All I have is a swagger document that indicates we need to send some sort of file contents with a Content-Type of "multipart/form-data".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants