代码之家  ›  专栏  ›  技术社区  ›  monstertjie_za

无效的延续令牌SDB

  •  1
  • monstertjie_za  · 技术社区  · 7 年前

    我正试图用延续令牌实现分页,但在用延续令牌调用函数时,我不断得到以下响应:

    Message“:”发生错误“, “ExceptionMessage”:“无效的延续令牌\r\n活动ID:0f79a65f-a9d2-49a8-8a9c-d33a8526bec8,Microsoft.Azure.Documents文档.Common/2.0.0.0,documentdb dotnet sdk/1.22.0主机/32位MicrosoftWindowsNT/6.2.9200.0

    这是我的Azure函数:这个函数最初将在没有令牌的情况下被调用,在第二页请求时,令牌将被传入。

    [FunctionName("GetAllPaged")]
    public static async Task<HttpResponseMessage> ReadAll(
        [HttpTrigger(AuthorizationLevel.Function, "get", Route = "GetAllPaged/{pageSize?}/{token?}")]HttpRequestMessage req,
        int? pageSize, string token, ILogger log, [Inject]IComponent<EventModel> component)
    {
        try
        {
            log.LogInformation("Get all events");
    
            var response = await component.GetAll_Paged(pageSize, token);
    
            return req.CreateResponse(HttpStatusCode.OK, response);
        }
        catch (Exception ex)
        {
            log.LogError(ex.Message, ex);
            return req.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
        }
    }
    

    在我第一次调用Azure函数时,使用url http://localhost:7071/api/Event/GetAllPaged/3 ,我得到以下回应:

        {
    "Continuation": {
        "token": "CDhbANnikwAGAAAAAAAAAA==",
        "range": {
            "min": "",
            "max": "FF"
        }
    },
    "Results": [
        {
            "id": "c428e1c4-48d5-47ae-9f37-c29cc3fc8696",
            "Description": "Test description nr: 64791",
            "User": "Test User"
        },
        {
            "id": "bab08fe7-da5c-48c6-971d-a14ef3eb5f4c",
            "Description": "Test description nr: 63486",
            "User": "Test User"
        },
        {
            "id": "9688acc2-4acf-4acd-a252-5481b5b4d450",
            "Description": "Test description nr: 86498",
            "User": "Test User"
        }
    ]
    }
    

    当我使用下一个对Azure函数的请求中提供的令牌时,使用带有令牌的url http://localhost:7071/api/Event/GetAllPaged/3/CDhbANnikwAGAAAAAAAAAA==

    1 回复  |  直到 7 年前
        1
  •  4
  •   monstertjie_za    7 年前

    我发现了我的错误。

    而不是通过:

    CDHBannikwagaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa==

    “{\”token\“:\”cdhbannikwaiaaaaaaaaaaaaa==\”,\”range\“:{\”min\“:\”,\”max\“:\”FF\“}}”

    推荐文章