c# - OneNote API Create Image showing red x -


Trying to capture an image on the OneNote API, using the Windows Store instance, is proving to be a bit tricky

I'm getting "red x" instead of image. It looks like the image source is not correct, but I've made several changes.

Below is my code: (any help Will be appreciated)

  private async zero btnCreatePage_Click (Object Sender, RoutedEventArgs E) {CreatePageWithImage () awaiting; } Private async works CreatePageWithImage () {var client = new HTTP client}; Client.DefaultRequestHeaders.Accept.Add (New MediaTypeWithQualityHeaderValue ("App / Jason")); If (ASApronic) {client.DefaultRequestHeaders.Authorization = new authentication header value ("bearer", authClient.Session.AccessToken); } Const string imagePartName = "property \\ asthma .jpg"; String date = getdate (); String Simple HTML = "& lt; html & gt;" + "& Lt; prime & gt;" + "& Lt; title & gt; A simple page created with an image on it & lt; / title & gt;" + "& Lt; Meta name = \" created \ "content = \" "+ date +" \ "/> + "& Lt; / head & gt;" + "& Lt; body & gt;" + "& Lt; h1> This is a ximage page with it & lt; / h1 & gt;" + "& Lt; img src = \" Name: "+ imagePartName +" \ "alt = \" A beautiful logo \ "width = \" 426 \ "height = \" 68 \ "/> + "& Lt; / body & gt;" + "& Lt; / html & gt;"; // Create the image part - Make sure that it has been settled after sending the message to stop the stream; HTPRPS messaging message response; Using {imageContent.Headers.ContentType = new MediaTypeHeaderValue ("image / jpeg") (on imageContent = new StreamContent (GetBinaryStream ("property \\ Asthma.jpg"))); HttpRequestMessage createMessage = new HttpRequestMessage (HttpMethod.Post, PagesEndPoint) {content = new MultipartFormDataContent {{New StringContent (simpleHtml, System.Text.Encoding.UTF8, "text / html"), "presentation"}, {imageContent, imagePartName}} }; // The request must be sent within the block, or the image stream will be disposed of. Response = wait client.SendAsync (createMessage); } TbResponse.Text = response.ToString (); }  

In your code, you have set the type of media to "type / jpg". Instead, you should have "image / JPEG" set to change. You also need to change imagePartName to delete "\".

- James ()


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -