PrepAway - Latest Free Exam Questions & Answers

Which HTTP request should you use?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create a Windows Communication
Foundation (WCF) Data Services service. You deploy the data service to the following URL: http://contoso.com/Northwind.svc.
You need to update the City property of the Customer record that has its ID value as 123.
You also need to preserve the current values of the remaining properties. Which HTTP request should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
PUT /Northwind.svc/Customers(123)
Host: contoso.com
Content-Type: application/json { City: ‘Seattle’ }

B.
PUT /Northwind.svc/Customers(123)
Host: contoso.com
Accept: application/json { City: ‘Seattle’ }

C.
MERGE /Northwind.svc/Customers(123)
Host: contoso.com
Content-Type: application/json { City: ‘Seattle’ }

D.
MERGE /Northwind.svc/Customers(123)
Host: contoso.com
Accept: application/json { City: ‘Seattle’ }

Explanation:
HTTP Actions
OData supports the following HTTP actions to perform create, read, update, and delete operations on the entity data that the addressed resource represents:
HTTP GET – This is the default action when a resource is accessed from a browser. No payload is supplied in the request message,
and a response method with a payload that contains the requested data is returned.
HTTP POST – Inserts new entity data into the supplied resource. Data to be inserted is supplied in the payload of the request message.
The payload of the response message contains the data for the newly created entity. This includes any autogenerated key values.
The header also contains the URI that addresses the new entity resource.
HTTP DELETE – Deletes the entity data that the specified resource represents. A payload is not present in the request or response messages.
HTTP PUT – Replaces existing entity data at the requested resource with new data that is supplied in the payload of the request message.
HTTP MERGE – Because of inefficiencies in executing a delete followed by an insert in the data source just to change entity data,
OData introduces a new HTTP MERGE action. The payload of the request message contains the properties
that must be changed on the addressed entity resource. Because HTTP MERGE is not defined in the HTTP specification,
it may require additional processing to route a HTTP MERGE request through non-OData aware servers.

Accessing and Changing Data Using REST Semantics
(http://msdn.microsoft.com/en-us/library/dd728282.aspx)

HTTP header fields
(http://en.wikipedia.org/wiki/List_of_HTTP_header_fields)
Accept Content-Types that are acceptable
Content-Type The mime type of the body of the request (used with POST and PUT requests)

A Guide to Designing and Building RESTful WebServices with WCF 3.5
(http://msdn.microsoft.com/en-us/library/dd203052.aspx)


Leave a Reply