Posts

Showing posts with the label Azure .NET backend

Resolve the "HTTP 404" error when calling a Azure Mobile App Service custom API (.NET backend)

I got the "HTTP 404 - method not found" error message when calling a  a Azure Mobile App custom API (.NET backend) from the Universal Windows App (UWP). The custom API is defined as following:         // GET api/GetStorageToken         [HttpGet, Route("api/GetStorageToken/{contName}")]         public async Task<StorageTokenViewModel> GetStorageToken(string containerName)         {                          .....          } I verified this issue and compared with the existing custom API which can be called successfully, and I found out the issue was the parameter name in the custom API different from the line above "   [HttpGet, Route("api/GetStorageToken/{ contName }")] ", once I updated it to    [HttpGet, Route("api/GetStorageToken/{ containerName }")], I can call this API successfully...

How to update device Installation's tags in Azure Mobile App Service .NET backend

It mentions that how to add Tags to Installation in this sample article https://blogs.msdn.microsoft.com/writingdata_services/2016/01/22/adding-push-notification-tags-from-an-azure-mobile-apps-client/ . But I need to update my tags in device installation not just adding new tags, and so I comment out the line of code "await hubClient.PatchInstallationAsync(Id, updates);", and then add following codes in my custom API controller in .NET backend.                // Verify that the tags are a valid JSON array.                 var tags = JArray.Parse(message);                 List<string> validTags = new List<string>();                 foreach (string tag in tags)                 {                          ...

Retrieve other table 's data within a TableController - Azure Mobile App Service .NET backend

I created a custom Table controller called "TaskItemController" in Azure Mobile App Service .NET backend and needs to retrieve data from other tables. I using the code "context.TodoItems.SqlQuery" to retrieve data from "TodoItems" table. The variable "context" is initialized in method "Initialize(HttpControllerContext controllerContext)" within table controller. The following is a sample code to retrieve data from other table "TodoItems". // POST tables/TaskItem  public async Task<IHttpActionResult> PostTaskItem(TaskItem item) {          var query = context.TodoItems.SqlQuery("Select * from TaskItems where Id='" + item.TaskId + "'").FirstOrDefault<TaskItem>();           //Get data column's value         var taskName=query.TaskName; }