1

I'm trying to save a PDF from QBO however I'm stuck on this bit: How do i get the IConsumerRequest to return a stream instead of a string? ReadBody only seems to send string rather than binary data...

IConsumerRequest conReq = oSession.Request();
conReq = conReq.Get().WithRawContentType("application/pdf");
string outURL = base_url + "invoice-document/v2/" + realmId + "/" + customerInvoicesWithinDateRange[0].Id.Value;
conReq = conReq.ForUrl(outURL);
conReq = conReq.SignWithToken();
string serviceResponse = conReq.ReadBody();

Thanks

Manas Mukherjee
  • 5,270
  • 3
  • 18
  • 30
safetyOtter
  • 1,430
  • 14
  • 26

1 Answers1

4

instead of conReeq.ReadBody(), you can do this:

conReq.ToWebResponse().GetResponseStream();

in fact, ReadBody() is simply an extension method on IConsumerRequest, defined as:

public static string ReadBody(this IConsumerRequest request)
{
  HttpWebResponse response = request.ToWebResponse();

  return response.ReadToEnd();
}
shrisha
  • 445
  • 2
  • 7