POST - Upload JSON
Optional upload endpoint that allows uploading files as base64 in an application/json payload.
Please supply a valid bearerToken and products or fieldSet or fieldSets.
- : Provides access to Fileupload Service
- : upload document
We use an Oauth2 authentication flow. Users can create a client_id and client_secret upon signing up with Sypht.
Use these to generate your reusable bearer token, which must be included in the Authorization header of each request. You can store
and reuse these tokens for up to an hour.
To get a token you need to POST to the tokenUrl with the client_id and grant_type in the request body
and colon separated, base64 encoded client_id and client_secret in a basic Authorization header.
For example Basic {Base64(client_id:client_secret)}
tags associated with your file
Array of products to predict on. Cannot be supplied with fieldSet or fieldSets
A single field set for extraction
Optionally use this parameter to extract an array of field sets. Needs to be a json array in a string.
File was successfully uploaded.
The unique identifier associated to this file and request.
Error
import requests
import base64
import json
url = 'https://api.sypht.com/fileupload/json'
payload = {'fieldSets': ["sypht.invoice","sypht.document"],
'file':{'name':{{name of file}},'base64':base64.b64encode(open({{path to file}},'rb').read())}}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer '+token
}
response = requests.request('POST', url, headers = headers, data = json.dumps(payload), allow_redirects = False)
print(response.text)
{
"fileId": "30d3e543-47c8-42e6-a6f6-40c50d199395",
"uploadedAt": "2018-05-15T04:23:14.027Z",
"status": "RECEIVED"
}Last updated
