static-pinkS
Voiceflow Partners2y ago
3 replies
static-pink

Where's the bug - RestSharp or Voiceflow?

I have a client with a large document library and part of our requirement is uploading PDFs to the VF KB.

I have used the VF C# sample code here https://developer.voiceflow.com/reference/post_v3alpha-knowledge-base-docs-upload

Using this code I always receive a 400 Bad Request when uploading PDFs, however text files upload OK.

If the encoding of the PDF attachment is forced to text/plain then PDFs will upload but are not parsed correctly by the VF API with thousands of encoded characters, a 3 chunk file becomes a 1000 chunk file.

I contacted VF support, here is their response:

I got my colleague to review your code, and he said this issue may arise because you are manually passing a FormBoundary, while RestSharp usually handles multipart boundaries automatically.
Additionally, because the .txt file upload is currently functional, this does not appear to be a bug, and is thus outside of the scope of Support.

'My code' is actually 'their code'. I have tried with and without manually added form boundaries and the problem remains, also if it works for text and not PDFs then I can't see how form boundaries can be the issue.

So my questions is: Can anybody get the Voiceflow RestSharp sample code to upload correctly encoded PDFs to the KB from outside the VF network?

It should be noted:
* Uploading using the VF website works OK.
* Uploads work OK when I use the native HTTP client.
* Uploading using RestSharp (as recommended by the documentation) from outside the VF network has the issue.
Was this page helpful?