【问题标题】:Azure api: The value for one of the HTTP headers is not in the correct format. HeaderName: Content-LengthAzure api:HTTP 标头之一的值格式不正确。 HeaderName:内容长度
【发布时间】:2020-05-28 22:58:04
【问题描述】:

我正在尝试使用邮递员调用 azure API“放置范围”函数。 我得到结果:

<?xml version="1.0" encoding="utf-8"?>
<Error>
    <Code>InvalidHeaderValue</Code>
    <Message>The value for one of the HTTP headers is not in the correct format.
RequestId:b131385d-301a-0044-31fd-344678000000
Time:2020-05-28T14:35:45.0769047Z</Message>
    <HeaderName>Content-Length</HeaderName>
    <HeaderValue>9</HeaderValue>
</Error>

我的请求有这些标头:

x-ms-write:Update
Range:bytes=0-3
Content-Length:9

正文包括:

一些文字

【问题讨论】:

    标签: azure azure-functions postman


    【解决方案1】:

    如果您注意到,您的 Range 标头只有 4 个字节 (0 - 3),但您的内容长度实际上是 9 个字节。这可能是您收到此错误的原因。

    请更改您的 Range 标头,使其发送 9 个字节。

    Range:bytes=0-8

    或者将您的内容长度标头更改为仅发送 4 个字节。

    【讨论】:

    • 谢谢这是问题所在。修复此问题后,我收到错误:"The range specified is invalid for the current size of the resource." 我通过首先调用 set file properties 函数并将文件长度从 0 设置为我需要的长度来解决此问题。
    • 虽然这解决了问题,但我认为这是一种不正确的方法。创建文件时,需要指定大小。请看这个:docs.microsoft.com/en-us/rest/api/storageservices/create-file.
    • 你是对的。正确的流程是 Create File -> Put Range
    猜你喜欢
    • 1970-01-01
    • 2020-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-01
    • 2018-06-01
    • 2012-12-02
    相关资源
    最近更新 更多