johnjohn-0472 avatar image
0 Votes"
johnjohn-0472 asked ·

Invoke-WebRequest a .SVC which is hosted inside Azure using Post method will return “The remote server returned an error: (404) Not Found” RRS feed

I have created an web application and inside it i created a .SVC service, then i deploy the application inside azure web app. now using the browser i can call the .SVC file and i will get the service wsdl as follow:-

but inside my SharePoint, i register the .SVC as a remote even receiver, and SharePoint will call this .SVC using POST request. but it will raise exception.

so to understand why the SVC is returning exception on Post, i tried to invoke the .SVC using power shell, and i got this result:-

Using Post:-

Invoke-WebRequest -Uri "https://****" -Method Post

Invoke-WebRequest : The remote server returned an error: (404) Not Found. At line:1 char:1
+ Invoke-WebRequest -Uri "https://**** ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Using Get:-

Invoke-WebRequest -Uri "https://***"

StatusCode : 200 StatusDescription : OK

So i am not sure why i can not call the .SVC using POST method.

here is the web.config:-

and here is the .SVC service:-

public class Service1 : IRemoteEventService
public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
string correlationID = properties.CorrelationId.ToString();
string siteUrl = properties.ItemEventProperties.WebUrl;
int listItemID = properties.ItemEventProperties.ListItemId;
Guid listID = properties.ItemEventProperties.ListId;

          Trace.TraceInformation("Calling ProcessOneWayEvent in ItemCreated. Correlation ID is {0}. Site url is {1}. List ID is {2}. List Item ID is {3}", correlationID, siteUrl, listID, listItemID);
          SPRemoteEventResult result = new SPRemoteEventResult();
          using (ClientContext context = Helpers.GetAppOnlyContext(siteUrl))
              result.ChangedItemProperties.Add("Title", "After adding");
              result.Status = SPRemoteEventServiceStatus.Continue;
      public void ProcessOneWayEvent(SPRemoteEventProperties properties)
          var prop = properties;
          var itemId = properties.ItemEventProperties.ListItemId;
          var listTitle = properties.ItemEventProperties.ListTitle;
          using (ClientContext clientContext = Helpers.GetAppOnlyContext(properties.ItemEventProperties.WebUrl))
              var list = clientContext.Site.RootWeb.Lists.GetByTitle("12");
              var item = list.GetItemById(properties.ItemEventProperties.ListItemId);
              item["Title"] = item["Title"] + "test";

111.png (34.4 KiB)
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers