crazyTech
crazyTech

Reputation: 1477

How to invoke a Web Service that requires the "patch" verb using the C# WebClient wrapper?

Our ASP.NET C# web application is used in the following environment -

-.NET Framework 4 - IIS 7 - Windows 2008 - Visual Studio 2012 - .NET IDE - C# - HTTPS ( SSL )

The Web Service Endpoint is on a third-party vendor.
The Web Service Endpoint uses the "patch" verb.

The third-party vendor specifications require that the Web Service Endpoint

1) needs an bigInt id for a particular resource 2) a "patch" verb

String address = string.Format("https://blah.blah.com/users/{0}?verb={1}",
                  Uri.EscapeDataString(vfuArg.ViaFouraUserId.ToString()), Uri.EscapeDataString("patch"));

However, the specifications also allows for other arguments that are Not in the url of the web service. The specifications are pretty brief.

I have named-value pairs declared as follows:

var values = new NameValueCollection{  { "email", loggedInUserRegisteredEmailArg }  };

I uploaded the data as follows:

    byte[] result = clientArg.UploadValues(address, values);
    var clientResponseForModifyingUser = Encoding.UTF8.GetString(result);

However, I get a 401 error.

Am I invoking "patch" verb properly with C# WebClient wrapper? I failed to find much online documentation on "patch" verb and the C# WebClient.

What should I change in the code snippets listed above in order to resolve the issue?

Upvotes: 0

Views: 2403

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1064114

The "verb" usually means the http method... "GET", POST", etc. It does not go on the query-string - it is specified in the call itself:

byte[] result = clientArg.UploadValues(address, "PATCH", values);

Upvotes: 2

Related Questions