Question 132 of 179 from exam AZ-204: Developing Solutions for Microsoft Azure

Question 132 of 179 from exam AZ-204: Developing Solutions for Microsoft Azure

Question

DRAG DROP - You are a developer for a Software as a Service (SaaS) company.

You develop solutions that provide the ability to send notifications by using Azure Notification Hubs.

You need to create sample code that customers can use as a reference for how to send raw notifications to Windows Push Notification Services (WNS) devices.

The sample code must not use external packages.

How should you complete the code segment? To answer, drag the appropriate code segments to the correct locations.

Each code segment may be used once, more than once, or not at all.

You may need to drag the split bar between panes or scroll to view content.

NOTE: Each correct selection is worth one point.

Select and Place:

Code segments

raw

windows

windowsphone

application/xml

application/json

application/octet-stream

Answer Area

var endpoint =
var payload
var request
request .Headers.Add("X-WNS-Type”, “wns/raw”);

new HttpRequestMessage (HttpMethod.Post, endpoint);

request .Headers.Add("ServiceBusNotification-Format”, “

Code segment

xequest.Content = new StringContent (payload, Encoding.UTF8, “
var client = new HttpClient();
await client.SendAsync (request) ;

my,

Code segment

bal

Explanations

Code segments

raw

windowsphone

application/xml

application/json

Answer Area

var endpoint =
var payload
var request
request .Headers.Add("X-WNS-Type”, “wns/raw”);

request .Headers.Add("ServiceBusNotification-Format”, “ | windows

xequest.Content = new StringContent (payload, Encoding.UTF8, “
var client = new HttpClient();
await client.SendAsync (request) ;

new HttpRequestMessage (HttpMethod.Post, endpoint);

my,

application/octet-stream

bal

Box 1: windows - Example code: var request = new HttpRequestMessage(method, $"{resourceUri}?api-version=2017-04"); request.Headers.Add("Authorization", createToken(resourceUri, KEY_NAME, KEY_VALUE)); request.Headers.Add("X-WNS-Type", "wns/raw"); request.Headers.Add("ServiceBusNotification-Format", "windows"); return request; Box 2: application/octet-stream - Example code capable of sending a raw notification: string resourceUri = $"https://{NH_NAMESPACE}.servicebus.windows.net/{HUB_NAME}/messages/"; using (var request = CreateHttpRequest(HttpMethod.Post, resourceUri)) { request.Content = new StringContent(content, Encoding.UTF8, "application/octet-stream"); request.Content.Headers.ContentType.CharSet = string.Empty; var httpClient = new HttpClient(); var response = await httpClient.SendAsync(request); Console.WriteLine(response.StatusCode); } Reference: https://stackoverflow.com/questions/31346714/how-to-send-raw-notification-to-azure-notification-hub/31347901