Get Pdf Rest Sharp (GET)





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







-2















I am testing a service to which you send a json and it returns a PDF with the data you sent it. I did tests with Insomnia as shown here:



test with insomnia



It works correctly, but trying to recover the file through code always generates an error. My code is the following:



var client = new RestClient("Api");
var request = new RestRequest(Method.GET);

request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{nt"QuotationId": 0,nt"QuotationName": "CasaLomas",nt"UserGUID": "75DB06AC-E349-4C47-A5AF-87EC63A9B8A9",nt"QuotedQuantity": 5,nt"TotalPrice": 500,nt"CopyEmail": "angelmg50@hotmail.com",nt"MaterialDetails": [ntt{nttt"SKU": "C05423082015140001",nttt"Name": "PORC KONE WHITE MATE 60x30x1",nttt"Quantity": 1,nttt"Price": 638.09,nttt"Amount": 6380ntt},ntt{nttt"SKU": "C05423082015140001",nttt"Name": "PORC KONE WHITE MATE 60x30x1",nttt"Quantity": 1,nttt"Price": 638.09,nttt"Amount": 6380ntt},ntt{nttt"SKU": "C05423082015140001",nttt"Name": "PORC KONE WHITE MATE 60x30x1",nttt"Quantity": 1,nttt"Price": 638.09,nttt"Amount": 6380ntt}nt]n}", ParameterType.RequestBody);

IRestResponse response = client.Execute(request);


This connects correctly with the API but apparently the json has not been sent correctly. Any idea why this happens?



I created the json with dynamic and tried to send it.



dynamic cotizacion = new JObject();

cotizacion.QuotationId = 0;
cotizacion.QuotationName = "Casa lomas 3";
cotizacion.UserGUID = "75DB06AC-E349-4C47-A5AF-87EC63A9B8A9";
cotizacion.QuotedQuantity = 6;
cotizacion.TotalPrice = 456.12;
cotizacion.CopyEmail = "angelmg50@hotmail.com";
cotizacion.MaterialDetails = new JArray(new JObject(
new JProperty("SKU", "C05423082015140001"),
new JProperty("Name", "PORC KONE WHITE MATE 60x30x1"),
new JProperty("Quantity", 1),
new JProperty("Price", 638.09),
new JProperty("Amount", 6380.30)));

var client = new RestClient("Api");
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", cotizacion, ParameterType.RequestBody);

IRestResponse response = client.Execute(request);


But this does not work either.



When I print response.Content in console it shows me the following: "Message": "Internal error when trying to generate the PDF" Value can not be null. R nParameter name: source "," StatusCode ": 3," Result ": null, "ResultList": null}










share|improve this question

























  • n t r tags are needed to be eliminated.

    – Derviş Kayımbaşıoğlu
    Nov 23 '18 at 19:00











  • I did it, but it still does not work. Any other idea?

    – Angel Martinez
    Nov 23 '18 at 19:17











  • you always need to provide exception/error details in order to get help for your issues

    – Derviş Kayımbaşıoğlu
    Nov 23 '18 at 19:20













  • The first idea is to never write JSON manually

    – Camilo Terevinto
    Nov 23 '18 at 19:20











  • I have edited my question to add more details.

    – Angel Martinez
    Nov 23 '18 at 19:39


















-2















I am testing a service to which you send a json and it returns a PDF with the data you sent it. I did tests with Insomnia as shown here:



test with insomnia



It works correctly, but trying to recover the file through code always generates an error. My code is the following:



var client = new RestClient("Api");
var request = new RestRequest(Method.GET);

request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{nt"QuotationId": 0,nt"QuotationName": "CasaLomas",nt"UserGUID": "75DB06AC-E349-4C47-A5AF-87EC63A9B8A9",nt"QuotedQuantity": 5,nt"TotalPrice": 500,nt"CopyEmail": "angelmg50@hotmail.com",nt"MaterialDetails": [ntt{nttt"SKU": "C05423082015140001",nttt"Name": "PORC KONE WHITE MATE 60x30x1",nttt"Quantity": 1,nttt"Price": 638.09,nttt"Amount": 6380ntt},ntt{nttt"SKU": "C05423082015140001",nttt"Name": "PORC KONE WHITE MATE 60x30x1",nttt"Quantity": 1,nttt"Price": 638.09,nttt"Amount": 6380ntt},ntt{nttt"SKU": "C05423082015140001",nttt"Name": "PORC KONE WHITE MATE 60x30x1",nttt"Quantity": 1,nttt"Price": 638.09,nttt"Amount": 6380ntt}nt]n}", ParameterType.RequestBody);

IRestResponse response = client.Execute(request);


This connects correctly with the API but apparently the json has not been sent correctly. Any idea why this happens?



I created the json with dynamic and tried to send it.



dynamic cotizacion = new JObject();

cotizacion.QuotationId = 0;
cotizacion.QuotationName = "Casa lomas 3";
cotizacion.UserGUID = "75DB06AC-E349-4C47-A5AF-87EC63A9B8A9";
cotizacion.QuotedQuantity = 6;
cotizacion.TotalPrice = 456.12;
cotizacion.CopyEmail = "angelmg50@hotmail.com";
cotizacion.MaterialDetails = new JArray(new JObject(
new JProperty("SKU", "C05423082015140001"),
new JProperty("Name", "PORC KONE WHITE MATE 60x30x1"),
new JProperty("Quantity", 1),
new JProperty("Price", 638.09),
new JProperty("Amount", 6380.30)));

var client = new RestClient("Api");
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", cotizacion, ParameterType.RequestBody);

IRestResponse response = client.Execute(request);


But this does not work either.



When I print response.Content in console it shows me the following: "Message": "Internal error when trying to generate the PDF" Value can not be null. R nParameter name: source "," StatusCode ": 3," Result ": null, "ResultList": null}










share|improve this question

























  • n t r tags are needed to be eliminated.

    – Derviş Kayımbaşıoğlu
    Nov 23 '18 at 19:00











  • I did it, but it still does not work. Any other idea?

    – Angel Martinez
    Nov 23 '18 at 19:17











  • you always need to provide exception/error details in order to get help for your issues

    – Derviş Kayımbaşıoğlu
    Nov 23 '18 at 19:20













  • The first idea is to never write JSON manually

    – Camilo Terevinto
    Nov 23 '18 at 19:20











  • I have edited my question to add more details.

    – Angel Martinez
    Nov 23 '18 at 19:39














-2












-2








-2








I am testing a service to which you send a json and it returns a PDF with the data you sent it. I did tests with Insomnia as shown here:



test with insomnia



It works correctly, but trying to recover the file through code always generates an error. My code is the following:



var client = new RestClient("Api");
var request = new RestRequest(Method.GET);

request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{nt"QuotationId": 0,nt"QuotationName": "CasaLomas",nt"UserGUID": "75DB06AC-E349-4C47-A5AF-87EC63A9B8A9",nt"QuotedQuantity": 5,nt"TotalPrice": 500,nt"CopyEmail": "angelmg50@hotmail.com",nt"MaterialDetails": [ntt{nttt"SKU": "C05423082015140001",nttt"Name": "PORC KONE WHITE MATE 60x30x1",nttt"Quantity": 1,nttt"Price": 638.09,nttt"Amount": 6380ntt},ntt{nttt"SKU": "C05423082015140001",nttt"Name": "PORC KONE WHITE MATE 60x30x1",nttt"Quantity": 1,nttt"Price": 638.09,nttt"Amount": 6380ntt},ntt{nttt"SKU": "C05423082015140001",nttt"Name": "PORC KONE WHITE MATE 60x30x1",nttt"Quantity": 1,nttt"Price": 638.09,nttt"Amount": 6380ntt}nt]n}", ParameterType.RequestBody);

IRestResponse response = client.Execute(request);


This connects correctly with the API but apparently the json has not been sent correctly. Any idea why this happens?



I created the json with dynamic and tried to send it.



dynamic cotizacion = new JObject();

cotizacion.QuotationId = 0;
cotizacion.QuotationName = "Casa lomas 3";
cotizacion.UserGUID = "75DB06AC-E349-4C47-A5AF-87EC63A9B8A9";
cotizacion.QuotedQuantity = 6;
cotizacion.TotalPrice = 456.12;
cotizacion.CopyEmail = "angelmg50@hotmail.com";
cotizacion.MaterialDetails = new JArray(new JObject(
new JProperty("SKU", "C05423082015140001"),
new JProperty("Name", "PORC KONE WHITE MATE 60x30x1"),
new JProperty("Quantity", 1),
new JProperty("Price", 638.09),
new JProperty("Amount", 6380.30)));

var client = new RestClient("Api");
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", cotizacion, ParameterType.RequestBody);

IRestResponse response = client.Execute(request);


But this does not work either.



When I print response.Content in console it shows me the following: "Message": "Internal error when trying to generate the PDF" Value can not be null. R nParameter name: source "," StatusCode ": 3," Result ": null, "ResultList": null}










share|improve this question
















I am testing a service to which you send a json and it returns a PDF with the data you sent it. I did tests with Insomnia as shown here:



test with insomnia



It works correctly, but trying to recover the file through code always generates an error. My code is the following:



var client = new RestClient("Api");
var request = new RestRequest(Method.GET);

request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{nt"QuotationId": 0,nt"QuotationName": "CasaLomas",nt"UserGUID": "75DB06AC-E349-4C47-A5AF-87EC63A9B8A9",nt"QuotedQuantity": 5,nt"TotalPrice": 500,nt"CopyEmail": "angelmg50@hotmail.com",nt"MaterialDetails": [ntt{nttt"SKU": "C05423082015140001",nttt"Name": "PORC KONE WHITE MATE 60x30x1",nttt"Quantity": 1,nttt"Price": 638.09,nttt"Amount": 6380ntt},ntt{nttt"SKU": "C05423082015140001",nttt"Name": "PORC KONE WHITE MATE 60x30x1",nttt"Quantity": 1,nttt"Price": 638.09,nttt"Amount": 6380ntt},ntt{nttt"SKU": "C05423082015140001",nttt"Name": "PORC KONE WHITE MATE 60x30x1",nttt"Quantity": 1,nttt"Price": 638.09,nttt"Amount": 6380ntt}nt]n}", ParameterType.RequestBody);

IRestResponse response = client.Execute(request);


This connects correctly with the API but apparently the json has not been sent correctly. Any idea why this happens?



I created the json with dynamic and tried to send it.



dynamic cotizacion = new JObject();

cotizacion.QuotationId = 0;
cotizacion.QuotationName = "Casa lomas 3";
cotizacion.UserGUID = "75DB06AC-E349-4C47-A5AF-87EC63A9B8A9";
cotizacion.QuotedQuantity = 6;
cotizacion.TotalPrice = 456.12;
cotizacion.CopyEmail = "angelmg50@hotmail.com";
cotizacion.MaterialDetails = new JArray(new JObject(
new JProperty("SKU", "C05423082015140001"),
new JProperty("Name", "PORC KONE WHITE MATE 60x30x1"),
new JProperty("Quantity", 1),
new JProperty("Price", 638.09),
new JProperty("Amount", 6380.30)));

var client = new RestClient("Api");
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", cotizacion, ParameterType.RequestBody);

IRestResponse response = client.Execute(request);


But this does not work either.



When I print response.Content in console it shows me the following: "Message": "Internal error when trying to generate the PDF" Value can not be null. R nParameter name: source "," StatusCode ": 3," Result ": null, "ResultList": null}







c# json rest pdf sharp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 21:05









mkl

55.8k1270150




55.8k1270150










asked Nov 23 '18 at 18:57









Angel MartinezAngel Martinez

43




43













  • n t r tags are needed to be eliminated.

    – Derviş Kayımbaşıoğlu
    Nov 23 '18 at 19:00











  • I did it, but it still does not work. Any other idea?

    – Angel Martinez
    Nov 23 '18 at 19:17











  • you always need to provide exception/error details in order to get help for your issues

    – Derviş Kayımbaşıoğlu
    Nov 23 '18 at 19:20













  • The first idea is to never write JSON manually

    – Camilo Terevinto
    Nov 23 '18 at 19:20











  • I have edited my question to add more details.

    – Angel Martinez
    Nov 23 '18 at 19:39



















  • n t r tags are needed to be eliminated.

    – Derviş Kayımbaşıoğlu
    Nov 23 '18 at 19:00











  • I did it, but it still does not work. Any other idea?

    – Angel Martinez
    Nov 23 '18 at 19:17











  • you always need to provide exception/error details in order to get help for your issues

    – Derviş Kayımbaşıoğlu
    Nov 23 '18 at 19:20













  • The first idea is to never write JSON manually

    – Camilo Terevinto
    Nov 23 '18 at 19:20











  • I have edited my question to add more details.

    – Angel Martinez
    Nov 23 '18 at 19:39

















n t r tags are needed to be eliminated.

– Derviş Kayımbaşıoğlu
Nov 23 '18 at 19:00





n t r tags are needed to be eliminated.

– Derviş Kayımbaşıoğlu
Nov 23 '18 at 19:00













I did it, but it still does not work. Any other idea?

– Angel Martinez
Nov 23 '18 at 19:17





I did it, but it still does not work. Any other idea?

– Angel Martinez
Nov 23 '18 at 19:17













you always need to provide exception/error details in order to get help for your issues

– Derviş Kayımbaşıoğlu
Nov 23 '18 at 19:20







you always need to provide exception/error details in order to get help for your issues

– Derviş Kayımbaşıoğlu
Nov 23 '18 at 19:20















The first idea is to never write JSON manually

– Camilo Terevinto
Nov 23 '18 at 19:20





The first idea is to never write JSON manually

– Camilo Terevinto
Nov 23 '18 at 19:20













I have edited my question to add more details.

– Angel Martinez
Nov 23 '18 at 19:39





I have edited my question to add more details.

– Angel Martinez
Nov 23 '18 at 19:39












1 Answer
1






active

oldest

votes


















1














https://github.com/restsharp/RestSharp/wiki/Recommended-Usage



It seems like you are trying to add a parameter with the name "application/json". You may need to specify the name of the parameter in the endpoint and use AddObject instead of AddParameter. We can help more if you can give us some more info on your endpoint.






share|improve this answer
























  • The endpoint was provided to me only to consume it. I know it works because I did tests with Insomnia. The Endpoint receives the json that I send and returns a PDF with the information of that json in bytes. Here is an example of what it receives and what it returns. [link] (i.stack.imgur.com/k9pJZ.png)

    – Angel Martinez
    Nov 23 '18 at 20:46












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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451751%2fget-pdf-rest-sharp-get%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














https://github.com/restsharp/RestSharp/wiki/Recommended-Usage



It seems like you are trying to add a parameter with the name "application/json". You may need to specify the name of the parameter in the endpoint and use AddObject instead of AddParameter. We can help more if you can give us some more info on your endpoint.






share|improve this answer
























  • The endpoint was provided to me only to consume it. I know it works because I did tests with Insomnia. The Endpoint receives the json that I send and returns a PDF with the information of that json in bytes. Here is an example of what it receives and what it returns. [link] (i.stack.imgur.com/k9pJZ.png)

    – Angel Martinez
    Nov 23 '18 at 20:46
















1














https://github.com/restsharp/RestSharp/wiki/Recommended-Usage



It seems like you are trying to add a parameter with the name "application/json". You may need to specify the name of the parameter in the endpoint and use AddObject instead of AddParameter. We can help more if you can give us some more info on your endpoint.






share|improve this answer
























  • The endpoint was provided to me only to consume it. I know it works because I did tests with Insomnia. The Endpoint receives the json that I send and returns a PDF with the information of that json in bytes. Here is an example of what it receives and what it returns. [link] (i.stack.imgur.com/k9pJZ.png)

    – Angel Martinez
    Nov 23 '18 at 20:46














1












1








1







https://github.com/restsharp/RestSharp/wiki/Recommended-Usage



It seems like you are trying to add a parameter with the name "application/json". You may need to specify the name of the parameter in the endpoint and use AddObject instead of AddParameter. We can help more if you can give us some more info on your endpoint.






share|improve this answer













https://github.com/restsharp/RestSharp/wiki/Recommended-Usage



It seems like you are trying to add a parameter with the name "application/json". You may need to specify the name of the parameter in the endpoint and use AddObject instead of AddParameter. We can help more if you can give us some more info on your endpoint.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 19:53









MariusMarius

867




867













  • The endpoint was provided to me only to consume it. I know it works because I did tests with Insomnia. The Endpoint receives the json that I send and returns a PDF with the information of that json in bytes. Here is an example of what it receives and what it returns. [link] (i.stack.imgur.com/k9pJZ.png)

    – Angel Martinez
    Nov 23 '18 at 20:46



















  • The endpoint was provided to me only to consume it. I know it works because I did tests with Insomnia. The Endpoint receives the json that I send and returns a PDF with the information of that json in bytes. Here is an example of what it receives and what it returns. [link] (i.stack.imgur.com/k9pJZ.png)

    – Angel Martinez
    Nov 23 '18 at 20:46

















The endpoint was provided to me only to consume it. I know it works because I did tests with Insomnia. The Endpoint receives the json that I send and returns a PDF with the information of that json in bytes. Here is an example of what it receives and what it returns. [link] (i.stack.imgur.com/k9pJZ.png)

– Angel Martinez
Nov 23 '18 at 20:46





The endpoint was provided to me only to consume it. I know it works because I did tests with Insomnia. The Endpoint receives the json that I send and returns a PDF with the information of that json in bytes. Here is an example of what it receives and what it returns. [link] (i.stack.imgur.com/k9pJZ.png)

– Angel Martinez
Nov 23 '18 at 20:46




















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451751%2fget-pdf-rest-sharp-get%23new-answer', 'question_page');
}
);

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







這個網誌中的熱門文章

Academy of Television Arts & Sciences

L'Équipe

1995 France bombings