Examples in generated documentation don't work
Closed this issue · 0 comments
CharlieDigital commented
Generated client library for the upload API using swagger against C# language and framework version .NET 3.5.
Created app and API key in Box dev console
Used code sample in FileUploadApi.md
using System;
using System.Diagnostics;
using IC.He.Sdk.Box.Upload.Api;
using IC.He.Sdk.Box.Upload.Client;
using IC.He.Sdk.Box.Upload.Model;
namespace Example
{
public class UploadFileExample
{
public void main()
{
// Configure OAuth2 access token for authorization: OAuth2Security
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new FileUploadApi();
var file = new System.IO.Stream(); // System.IO.Stream | File to upload
string attributes = "{\"name\": \"10KB.pdf\", \"parent\": { \"id\": \"0\" } }";
try
{
// Upload File
FileList result = apiInstance.UploadFile(file, attributes);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling FileUploadApi.UploadFile: " + e.Message );
}
}
}
}
Specified attributes according to the documentation: https://developer.box.com/v2.0/reference#upload-a-file
Received the following response when uploading using the API:
HTTP/1.1 408 Request body incomplete
Date: Tue, 12 Sep 2017 19:38:03 GMT
Content-Type: text/html; charset=UTF-8
Connection: close
Cache-Control: no-cache, must-revalidate
Timestamp: 15:38:03.369
The request body did not contain the specified number of bytes. Got 155, expected 206
Here is the raw request:
POST https://upload.box.com/api/2.0/files/content HTTP/1.1
Accept: application/json
Authorization: Bearer {MY_APP_TOKEN_HERE}
User-Agent: Swagger-Codegen/1.0.0/csharp
Content-Type: multipart/form-data; boundary=-----------------------------28947758029299
Host: upload.box.com
Content-Length: 206
Accept-Encoding: gzip, deflate
Connection: Keep-Alive