How to parse multi-part form data from Web API response in c#How can I return NULL from a generic method in C#?HTTP POST in .NET doesn't workHow to copy data to clipboard in C#How can I parse JSON with C#?How to call asynchronous method from synchronous method in C#?How do I make calls to a REST api using C#?How to secure an ASP.NET Web APIHttpWebResponse text does not appear to be JSONMaking HttpWebRequest with “If-None-Match” Header (Etag)C# Parse JSON response (Get a specific part from response)
Does the talk count as invited if my PI invited me?
Cycling to work - 30mile return
Can more than one instance of Bend Luck be applied to the same roll by multiple Wild Magic sorcerers?
French equivalent of the German expression "flöten gehen"
In Dutch history two people are referred to as "William III"; are there any more cases where this happens?
Driving a school bus in the USA
Error when running ((x++)) as root
Is my company merging branches wrong?
How to draw pentagram-like shape in Latex?
RegEx with d doesn’t work in if-else statement with [[
Was Tyrion always a poor strategist?
Who is frowning in the sentence "Daisy looked at Tom frowning"?
Failing students when it might cause them economic ruin
Good examples of "two is easy, three is hard" in computational sciences
How was the blinking terminal cursor invented?
how to create an executable file for an AppleScript?
Are there any symmetric cryptosystems based on computational complexity assumptions?
Why would company (decision makers) wait for someone to retire, rather than lay them off, when their role is no longer needed?
What's is the easiest way to purchase a stock and hold it
Told to apply for UK visa before other visas
How to get all possible paths in 0/1 matrix better way?
How to laser-level close to a surface
FIFO data structure in pure C
Taylor series leads to two different functions - why?
How to parse multi-part form data from Web API response in c#
How can I return NULL from a generic method in C#?HTTP POST in .NET doesn't workHow to copy data to clipboard in C#How can I parse JSON with C#?How to call asynchronous method from synchronous method in C#?How do I make calls to a REST api using C#?How to secure an ASP.NET Web APIHttpWebResponse text does not appear to be JSONMaking HttpWebRequest with “If-None-Match” Header (Etag)C# Parse JSON response (Get a specific part from response)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I need to parse a web API response data where has a JSON response and an Image in Plain text. I tried to split this response by --Boundary. after splitting this I can easily parse JSON data but I cannot generate the image files. I also try to generate base64 plain text to Image generator online but failed.
The response stream looks something like this:
--BOUNDARY
Content-Type: application/json; name="Live_Info"
json data
--BOUNDARY
Content-Type: image/jpeg; name="Live_data"
Live image plain text data
ex: ÿØÿÛ C
#%$""!&+7/&)4)!"0A149;>>>%.DIC<H7=>;ÿÛ C
;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ÿÀ
--BOUNDARY
Here is my code which I had tried
HttpWebRequest webrequestlive =
(HttpWebRequest)WebRequest.Create(request_uri_live);
try
webrequestlive.KeepAlive = false;
HttpWebResponse webresponselive =
(HttpWebResponse)webrequestlive.GetResponse();
if (webresponselive.StatusCode == HttpStatusCode.OK)
Stream stream = webresponselive.GetResponseStream();
StreamReader reader = new StreamReader(stream);
var html_body = reader.ReadToEnd();
byte[] imageBytes;
string[] split = html_body.Split(new string[] "--
BOUNDARYrn" , StringSplitOptions.None);
LiveImageRetrievalCommandJOSNParser.Rootobject obj1 =
JsonConvert.DeserializeObject<
LiveImageRetrievalCommandJOSNParser.Rootobject> (split[0]);
byte[] imagedata = Encoding.UTF8.GetBytes(split[2]);
using (var imagestream = new MemoryStream(imagedata ))
using (BinaryReader br = new
BinaryReader(imagestream))
imageBytes = br.ReadBytes(500000);
br.Close();
//Image LiveImage = Image.FromStream(imagestream);
Image liveimage = (Bitmap)((new
ImageConverter()).ConvertFrom(imageBytes));
liveIMage.Image = liveimage;
stream.Close();
webresponselive.Close();
else
webrequestlive.Abort();
Thread.Sleep(5000);
ErrorLog("Bad Request for getting Live Image");
catch (Exception exer)
webrequestlive.Abort();
Thread.Sleep(5000);
ErrorLog(exer.Message);
After parsing, the actual results of this stream are JSON data and an Image.
c# api web response
add a comment |
I need to parse a web API response data where has a JSON response and an Image in Plain text. I tried to split this response by --Boundary. after splitting this I can easily parse JSON data but I cannot generate the image files. I also try to generate base64 plain text to Image generator online but failed.
The response stream looks something like this:
--BOUNDARY
Content-Type: application/json; name="Live_Info"
json data
--BOUNDARY
Content-Type: image/jpeg; name="Live_data"
Live image plain text data
ex: ÿØÿÛ C
#%$""!&+7/&)4)!"0A149;>>>%.DIC<H7=>;ÿÛ C
;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ÿÀ
--BOUNDARY
Here is my code which I had tried
HttpWebRequest webrequestlive =
(HttpWebRequest)WebRequest.Create(request_uri_live);
try
webrequestlive.KeepAlive = false;
HttpWebResponse webresponselive =
(HttpWebResponse)webrequestlive.GetResponse();
if (webresponselive.StatusCode == HttpStatusCode.OK)
Stream stream = webresponselive.GetResponseStream();
StreamReader reader = new StreamReader(stream);
var html_body = reader.ReadToEnd();
byte[] imageBytes;
string[] split = html_body.Split(new string[] "--
BOUNDARYrn" , StringSplitOptions.None);
LiveImageRetrievalCommandJOSNParser.Rootobject obj1 =
JsonConvert.DeserializeObject<
LiveImageRetrievalCommandJOSNParser.Rootobject> (split[0]);
byte[] imagedata = Encoding.UTF8.GetBytes(split[2]);
using (var imagestream = new MemoryStream(imagedata ))
using (BinaryReader br = new
BinaryReader(imagestream))
imageBytes = br.ReadBytes(500000);
br.Close();
//Image LiveImage = Image.FromStream(imagestream);
Image liveimage = (Bitmap)((new
ImageConverter()).ConvertFrom(imageBytes));
liveIMage.Image = liveimage;
stream.Close();
webresponselive.Close();
else
webrequestlive.Abort();
Thread.Sleep(5000);
ErrorLog("Bad Request for getting Live Image");
catch (Exception exer)
webrequestlive.Abort();
Thread.Sleep(5000);
ErrorLog(exer.Message);
After parsing, the actual results of this stream are JSON data and an Image.
c# api web response
add a comment |
I need to parse a web API response data where has a JSON response and an Image in Plain text. I tried to split this response by --Boundary. after splitting this I can easily parse JSON data but I cannot generate the image files. I also try to generate base64 plain text to Image generator online but failed.
The response stream looks something like this:
--BOUNDARY
Content-Type: application/json; name="Live_Info"
json data
--BOUNDARY
Content-Type: image/jpeg; name="Live_data"
Live image plain text data
ex: ÿØÿÛ C
#%$""!&+7/&)4)!"0A149;>>>%.DIC<H7=>;ÿÛ C
;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ÿÀ
--BOUNDARY
Here is my code which I had tried
HttpWebRequest webrequestlive =
(HttpWebRequest)WebRequest.Create(request_uri_live);
try
webrequestlive.KeepAlive = false;
HttpWebResponse webresponselive =
(HttpWebResponse)webrequestlive.GetResponse();
if (webresponselive.StatusCode == HttpStatusCode.OK)
Stream stream = webresponselive.GetResponseStream();
StreamReader reader = new StreamReader(stream);
var html_body = reader.ReadToEnd();
byte[] imageBytes;
string[] split = html_body.Split(new string[] "--
BOUNDARYrn" , StringSplitOptions.None);
LiveImageRetrievalCommandJOSNParser.Rootobject obj1 =
JsonConvert.DeserializeObject<
LiveImageRetrievalCommandJOSNParser.Rootobject> (split[0]);
byte[] imagedata = Encoding.UTF8.GetBytes(split[2]);
using (var imagestream = new MemoryStream(imagedata ))
using (BinaryReader br = new
BinaryReader(imagestream))
imageBytes = br.ReadBytes(500000);
br.Close();
//Image LiveImage = Image.FromStream(imagestream);
Image liveimage = (Bitmap)((new
ImageConverter()).ConvertFrom(imageBytes));
liveIMage.Image = liveimage;
stream.Close();
webresponselive.Close();
else
webrequestlive.Abort();
Thread.Sleep(5000);
ErrorLog("Bad Request for getting Live Image");
catch (Exception exer)
webrequestlive.Abort();
Thread.Sleep(5000);
ErrorLog(exer.Message);
After parsing, the actual results of this stream are JSON data and an Image.
c# api web response
I need to parse a web API response data where has a JSON response and an Image in Plain text. I tried to split this response by --Boundary. after splitting this I can easily parse JSON data but I cannot generate the image files. I also try to generate base64 plain text to Image generator online but failed.
The response stream looks something like this:
--BOUNDARY
Content-Type: application/json; name="Live_Info"
json data
--BOUNDARY
Content-Type: image/jpeg; name="Live_data"
Live image plain text data
ex: ÿØÿÛ C
#%$""!&+7/&)4)!"0A149;>>>%.DIC<H7=>;ÿÛ C
;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ÿÀ
--BOUNDARY
Here is my code which I had tried
HttpWebRequest webrequestlive =
(HttpWebRequest)WebRequest.Create(request_uri_live);
try
webrequestlive.KeepAlive = false;
HttpWebResponse webresponselive =
(HttpWebResponse)webrequestlive.GetResponse();
if (webresponselive.StatusCode == HttpStatusCode.OK)
Stream stream = webresponselive.GetResponseStream();
StreamReader reader = new StreamReader(stream);
var html_body = reader.ReadToEnd();
byte[] imageBytes;
string[] split = html_body.Split(new string[] "--
BOUNDARYrn" , StringSplitOptions.None);
LiveImageRetrievalCommandJOSNParser.Rootobject obj1 =
JsonConvert.DeserializeObject<
LiveImageRetrievalCommandJOSNParser.Rootobject> (split[0]);
byte[] imagedata = Encoding.UTF8.GetBytes(split[2]);
using (var imagestream = new MemoryStream(imagedata ))
using (BinaryReader br = new
BinaryReader(imagestream))
imageBytes = br.ReadBytes(500000);
br.Close();
//Image LiveImage = Image.FromStream(imagestream);
Image liveimage = (Bitmap)((new
ImageConverter()).ConvertFrom(imageBytes));
liveIMage.Image = liveimage;
stream.Close();
webresponselive.Close();
else
webrequestlive.Abort();
Thread.Sleep(5000);
ErrorLog("Bad Request for getting Live Image");
catch (Exception exer)
webrequestlive.Abort();
Thread.Sleep(5000);
ErrorLog(exer.Message);
After parsing, the actual results of this stream are JSON data and an Image.
c# api web response
c# api web response
asked Mar 23 at 16:59
Rukunujjaman MiajiRukunujjaman Miaji
11
11
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55316186%2fhow-to-parse-multi-part-form-data-from-web-api-response-in-c-sharp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55316186%2fhow-to-parse-multi-part-form-data-from-web-api-response-in-c-sharp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown