Working examples of the OpenAPI generated clients?
I am using the clients generated from the OpenAPI specification: https://github.com/box/box-openapi
Client code generated for C# targeting .NET framework 3.5; all resultant client libraries build without issue.
I created an app in the dev console and retrieved the auth token.
I am using the following code sample from the generated documentation:
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 = "{MY_ACCESS_TOKEN_HERE}"; 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 ); } } } }
When I make the API call, I see the following outgoing HTTP message:
POST https://upload.box.com/api/2.0/files/content HTTP/1.1 Accept: application/json Authorization: Bearer {MY_APP_AUTH_TOKEN} User-Agent: Swagger-Codegen/1.0.0/csharp Content-Type: multipart/form-data; boundary=-----------------------------2894***phone number removed for privacy***Host: upload.box.com Content-Length: 206 Accept-Encoding: gzip, deflate Connection: Keep-Alive
And the following response message:
HTTP/1.1 408 Request body incomplete Date: Tue, 12 Sep 2017 20:51:31 GMT Content-Type: text/html; charset=UTF-8 Connection: close Cache-Control: no-cache, must-revalidate Timestamp: 16:51:31.782 The request body did not contain the specified number of bytes. Got 155, expected 206
Not sure if this is user error or an issue with the client generation.
Are there any practical examples of working with the OpenAPI based clients?
-
Hi c-digs,
your call seems to be just fine. The issue might be because of the compression, the length being uncompressed but the actual body compressed.
Accept-Encoding: gzip, deflate
Can you file an issue against the repo here: https://github.com/box/box-openapi/issues ?
Please sign in to leave a comment.
Comments
1 comment