Hi
It is giving error NimbusAPi.shipping.root has some Invalid arguments. In response below data is returned
{"status":true,"data":"htts:\/\/nimubs-assets.s3.amazonaws.com\/manifest\/20230116150815-95.pdf"}
dynamic json = JsonConvert.DeserializeObject(response.Content);
JavaScriptSerializer serializer = new JavaScriptSerializer();
Root root = serializer.Deserialize(json);
using (WebClient webClient = new WebClient())
{
byte[] bytes = webClient.DownloadData(root.data);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(root.data));
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}
Pasang TamangPosted Jan 16, 2023, 1:54 PM
Hi,
What I notice in your response example is either you made typo while copying or you are getting wrong data. In your data I see htts. That should be https. You should receive response like this {"status":true,"data":"https:\/\/nimubs-assets.s3.amazonaws.com\/manifest\/20230116150815-95.pdf"}. And with Newtonsoft.Json you can do as in below code example.
Regards,
Pasang
Sachin SinghPosted Jan 16, 2023, 10:35 AM
then if it is deserializing correctly then it should download?
is it deserializing correctly? JsonConvert.Deserialize not giving any error?
Ramco RamcoPosted Jan 16, 2023, 10:09 AM
Hi Sachin
that is not the issue . I have done that because otherwise i am able to raise issue on forum
Thanks
Sachin SinghPosted Jan 16, 2023, 10:06 AM
make htts to https in your url (root.data). there is no scheme like htts.
Ramco RamcoPosted Jan 16, 2023, 9:59 AM
Hi Sachin
I want to get the pdf file downloaded from the data returned by Api
Thanks
Naimish MakwanaPosted Jan 16, 2023, 9:55 AM
Use Newtonsoft.Json and try below code.
Sachin SinghPosted Jan 16, 2023, 9:54 AM
Is your root class like this?