azure sdk deleteAsync 请求内容 null

Posted

技术标签:

【中文标题】azure sdk deleteAsync 请求内容 null【英文标题】:azure sdk deleteAsync request content null 【发布时间】:2015-03-01 16:30:08 【问题描述】:

我有一个带有 .NET 后端的 azure 移动服务,但无法删除记录。当我调试到 Delete 函数时,该项目为空。当我在即时窗口中调用 this.Request 时,我得到了底部返回的字符串。我曾经使用 node js 后端,但已经切换到 .NET 后端,所以客户端代码没有改变。

Review Item 类:

public class ReviewItem

    public string Id  get; set; 
    public string Line1  get; set; 
    public string Line2  get; set; 
    public string Line3  get; set; 
    public string Line4  get; set; 
    public System.DateTime LastUpdated  get; set; 
  

客户端:

var dbReviewItems = await reviewTable.ToListAsync();
foreach (var item in dbReviewItems)
    await reviewTable.DeleteAsync(item);

服务器端:

public void Delete(T item)

    Context.Delete(item.Id);
    Context.SaveChanges();

上下文:

// passing in Id because passing the item caused a not found exception
public T Delete(string Id) 

    var item = Find(Id);
    if (item == null) return null;
    return Context.Set<T>().Remove(item);

控制器的请求(在 azure 服务器上以调试模式运行,从 wp 模拟器调用):

Method: DELETE, RequestUri: 'https://xxxx.azure-mobile.net/tables/ReviewItem/016f5328-c6fa-4b14-9c41-73976a0afda8', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:  
  
  Cache-Control: no-cache  
  Connection: Keep-Alive  
  Accept: application/json  
  Accept-Encoding: gzip  
  Host: xxxx.azure-mobile.net  
  Max-Forwards: 10  
  User-Agent: ZUMO/1.3  
  User-Agent: (lang=Managed; os=Windows Phone; os_version=8.10.0.12358; arch=Win32NT; version=1.3.21121.0)  
  X-ZUMO-FEATURES: TT  
  X-ZUMO-INSTALLATION-ID: xxxx  
  X-ZUMO-APPLICATION: xxxx  
  X-ZUMO-AUTH: xxxx  
  X-ZUMO-VERSION: ZUMO/1.3 (lang=Managed; os=Windows Phone; os_version=8.10.0.12358; arch=Win32NT; version=1.3.21121.0)  
  X-LiveUpgrade: 1  
  X-ARR-LOG-ID: xxxx  
  DISGUISED-HOST: xxxx.azure-mobile.net  
  X-SITE-DEPLOYMENT-ID: xxxx  
  X-Original-URL: /tables/ReviewItem/016f5328-c6fa-4b14-9c41-73976a0afda8  
  X-Forwarded-For: 70.186.182.236:4945  
  X-ARR-SSL: 2048|128|DC=com, DC=microsoft, DC=corp, DC=redmond, CN=MSIT Machine Auth CA 2|C=US, S=WA, L=Redmond, O=Microsoft, OU=OrganizationName, CN=*.azurewebsites.net  
  Content-Length: 0  
  
    Content: System.Net.Http.StreamContent  
    Headers: Cache-Control: no-cache  
Connection: Keep-Alive  
Accept: application/json  
Accept-Encoding: gzip  
Host: xxxx.azure-mobile.net  
Max-Forwards: 10  
User-Agent: ZUMO/1.3 (lang=Managed; os=Windows Phone; os_version=8.10.0.12358; arch=Win32NT; version=1.3.21121.0)  
X-ZUMO-FEATURES: TT  
X-ZUMO-INSTALLATION-ID: xxxx  
X-ZUMO-APPLICATION: xxxx  
X-ZUMO-AUTH: xxxx  
X-ZUMO-VERSION: ZUMO/1.3 (lang=Managed; os=Windows Phone; os_version=8.10.0.12358; arch=Win32NT; version=1.3.21121.0)  
X-LiveUpgrade: 1  
X-ARR-LOG-ID: a252fe87-03c9-487a-87c8-aa454c906f79  
DISGUISED-HOST: xxxx.azure-mobile.net  
X-SITE-DEPLOYMENT-ID: xxxx  
X-Original-URL: /tables/ReviewItem/016f5328-c6fa-4b14-9c41-73976a0afda8  
X-Forwarded-For: 70.186.182.236:4945  
X-ARR-SSL: 2048|128|DC=com, DC=microsoft, DC=corp, DC=redmond, CN=MSIT Machine Auth CA 2|C=US, S=WA, L=Redmond, O=Microsoft, OU=OrganizationName, CN=*.azurewebsites.net  
  
    Method: DELETE  
    Properties: Count = 11  
    RequestUri: https://xxxx.azure-mobile.net/tables/ReviewItem/016f5328-c6fa-4b14-9c41-73976a0afda8  
    Version: 1.1

【问题讨论】:

【参考方案1】:

我是个笨蛋。我让控制器的删除方法接收一个对象。它应该接收一个字符串 ID。

【讨论】:

以上是关于azure sdk deleteAsync 请求内容 null的主要内容,如果未能解决你的问题,请参考以下文章

创建 Azure 恢复服务保管库 - Python SDK - 错误请求

Azure Blob PHP SDK - 直接从自定义多部分 API 请求上传到 Azure 存储

使用 Azure 存储 PHP SDK 时出现“其中一个请求输入超出范围”

适用于 blob 的 Azure Java SDK - 已请求加载默认 HttpClient 提供程序,但在类路径中找不到该提供程序

在 Azure 网站中使用 Azure SDK 时出现间歇性 SSL/TLS 错误

client.DeleteAsync - 在正文中包含对象