Conversation
e8bd81c to
2715277
Compare
This comment was marked as resolved.
This comment was marked as resolved.
2715277 to
373ad08
Compare
This comment was marked as resolved.
This comment was marked as resolved.
YoshiRulz
left a comment
There was a problem hiding this comment.
I'm not sure if the name "raw" is apt, since it's taking text rather than a bytestream.
| { | ||
| return Post( | ||
| url ?? PostUrl, | ||
| new StringContent(payload, Encoding.UTF8, contentType), |
There was a problem hiding this comment.
I set up ContentObjectFor above for you—it should be simply
-#pragma warning disable BHI1005 // exception type
- _ => throw new NotImplementedException()
+ /*MIME_PLAINTEXT,*/ _ => new StringContent(payload, Encoding.UTF8, mimeType)
-#pragma warning restore BHI1005but I'm now realising it shouldn't have [ConstantExpected] and also that the method can be public static. I'll fix that in a minute.
There was a problem hiding this comment.
I chose "raw" because it was all I could think of to differentiate from the existing one that submits a form. Technically that one takes text as well. This one just posts the text as the payload directly instead of forcing it into a form value.
There was a problem hiding this comment.
Ah, I hadn't seen the extra method. Not sure why it's really needed since there would still be different methods to pass in the different mimeTypes anyway....and for the raw post method I'm exposing the contentType header not to allow encoding the string differently but to allow the script author to set the header as appropriate. This library doesn't need to create a different content object if it's "text/plain" or "application/json". The incoming string is still just a string that's send as the body of the request as StringContent.
Adds
comm.httpPostRawwhich supports setting theContent-Typeand sends the supplied payload string verbatim instead of forcing it into a form field like httpPost.Check if completed:
Note: Also includes #4188