当filename超过136个字符时,OneDrive API upload.createSession返回400错误

时间:2016-10-12 17:57:25

标签: onedrive

当文件名超过136个字符时,OneDrive APi upload.createSession会抛出400错误。

以下请求成功。

-- Trains NN to recognize the function:
-- f(x_1, x_2) = (x_1 * x_2 > 0).

-- We're going to use neural networks
require 'nn'

-- Set up our neural network
--[[       2             20          20             1
  input[1] -- /--------\ -- /------\ -- /--------\
              | linear | -- | tanh | -- | linear | -- output
  input[2] -- \--------/ -- \------/ -- \--------/
]]--

mlp = nn.Sequential();
inputs = 2; outputs = 1; HUs = 20;
mlp:add(nn.Linear(inputs, HUs));
mlp:add(nn.Tanh());
mlp:add(nn.Linear(HUs, outputs))

-- We want MSE
criterion = nn.MSECriterion()

-- Give 2500 points of training data
print("Iterating...")
for i = 1,2500 do
  local input = torch.randn(2);
  local output = torch.Tensor(1);
  if (input[1] * input[2] > 0) then
    output[1] = -1
  else
    output[1] = 1
  end

  criterion:forward(mlp:forward(input), output)

  mlp:zeroGradParameters()
  mlp:backward(input, criterion:backward(mlp.output, output))
  mlp:updateParameters(0.01)
end
print("Model Trained...")

-- Test model
x = torch.Tensor(2)
x[1] =  0.5; x[2] =  0.5; print(mlp:forward(x));
x[1] =  0.5; x[2] = -0.5; print(mlp:forward(x));
x[1] = -0.5; x[2] =  0.5; print(mlp:forward(x));
x[1] = -0.5; x[2] = -0.5; print(mlp:forward(x));

但是如果你在文件名中添加另一个字符,(例如将扩展名从doc更改为docx)

POST /v1.0/drive/items/root:/sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc1.doc:/upload.createSession HTTP/1.1
Host: api.onedrive.com
Content-Type: application/json
Authorization: Bearer {INSERT_TOKEN}
Cache-Control: no-cache

{"item":{"name":"sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc1.doc",
         "@name.conflictBehavior":"rename"}}

我们得到以下回复。

POST /v1.0/drive/items/root:/sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc1.docx:/upload.createSession HTTP/1.1
Host: api.onedrive.com
Content-Type: application/json
Authorization: Bearer {INSERT_TOKEN}
Cache-Control: no-cache

{"item":{"name":"sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc_sample_doc1.docx",
         "@name.conflictBehavior":"rename"}}

这与您尝试上传到的文件夹的深度无关。有谁知道如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

这似乎是服务中的任意限制,而不是您如何拨打电话的问题。因此,我将此作为答案,而不是评论 - 您无能为力。

我们会使用the issue you opened跟踪问题,并且只会在那里显示更多更新。