SBarnes wrote:Is there a working example anywhere of using httputils with an apikey and a post that returns data in the body of the call, test code form Jiwa's test suite if it exists would suffice?
// This is the actual POST to the webhook
subscription.URL.PostStringToUrl(message.Body,
requestFilter: webRequest =>
{
foreach (SY_WebhookSubscriptionRequestHeader subscriptionRequestHeader in subscriptionRequestHeaders)
{
webRequest.Headers[subscriptionRequestHeader.Name] = subscriptionRequestHeader.Value;
}
});
responseFilter: webResponse =>
{
System.IO.Stream receiveStream = webResponse.GetResponseStream();
System.IO.StreamReader readStream = new System.IO.StreamReader( receiveStream);
string response = readStream.ReadToEnd();
}
SBarnes wrote:Thanks Mike,
I am aware of that bit from the REST api I was more after how you get the response's content. I found AddBearerToken as an extension method that I think will take care of the api key but I am unsure how the response works by the look of what I found I think you ned to do something like this but was wondering if there is something simpler that doesn't require the stream to get at it?
- Code: Select all
responseFilter: webResponse =>
{
System.IO.Stream receiveStream = webResponse.GetResponseStream();
System.IO.StreamReader readStream = new System.IO.StreamReader( receiveStream);
string response = readStream.ReadToEnd();
}
Users browsing this forum: No registered users and 1 guest