Last active
August 29, 2015 13:55
-
-
Save brianly/8722852 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public T Post<T>(string path, IEnumerable<KeyValuePair<string, string>> parameters, FilePayload payload) | |
{ | |
using (var restClient = new RestClient()) | |
{ | |
using (var content = new MultipartFormDataContent()) | |
{ | |
content.Add(new FormUrlEncodedContent(parameters)); | |
var streamContent = new StreamContent(new MemoryStream(payload.ContentBytes)); | |
content.Add(streamContent, "attachment1", payload.FileName); | |
var postMessage = restClient.CreateMessage(BuildUrl(path), HttpMethod.Post, _accessToken, content); | |
var task = restClient.SendAsync(postMessage); | |
return restClient.DeserializeResult<T>(task); | |
} | |
} | |
} | |
POST https://www.yammer.com/api/v1/messages.json HTTP/1.1 | |
Authorization: Bearer REMOVED | |
User-Agent: YammerApiClient (www.brianlyttle.com) | |
Content-Type: multipart/form-data; boundary="f1899122-117b-436b-a610-412771d6efa8" | |
Host: www.yammer.com | |
Content-Length: 9606 | |
Expect: 100-continue | |
Connection: Keep-Alive | |
--f1899122-117b-436b-a610-412771d6efa8 | |
Content-Type: application/x-www-form-urlencoded | |
Content-Disposition: form-data | |
body=This+is+a+test+from+code. | |
--f1899122-117b-436b-a610-412771d6efa8 | |
Content-Disposition: form-data; name=attachment1; filename=mike.jpg; filename*=utf-8''mike.jpg | |
�����JFIF��H�H�����"Exif��MM�*�����������������XICC_PROFILE��� | |
///// THE FOLLOWING HTTP REQUEST USING KDAVIE'S OLD CODE WORKED FINE ////// | |
POST https://www.yammer.com/api/v1/messages/ HTTP/1.1 | |
Content-Type: multipart/form-data; boundary=XZQVNHVS[DMLVOXFWILMERKNZI | |
Authorization: Bearer REMOVED | |
Cache-Control: no-cache | |
Host: www.yammer.com | |
Content-Length: 395490 | |
Expect: 100-continue | |
Connection: Keep-Alive | |
--XZQVNHVS[DMLVOXFWILMERKNZI | |
Content-Disposition: form-data; name="body" | |
This is a message | |
--XZQVNHVS[DMLVOXFWILMERKNZI | |
Content-Disposition: form-data; name="attachment1"; filename="mike.jpg" | |
Content-type: text/xml | |
�����JFIF��H�H����XICC_PROFILE��� |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment