Title Upload JSON objects in order to register entries in RawData table

  • The client is supposed to upload JSON objects
  • The server will handle the request and will update the database properly

URL /upload
Method GET | POST

  • If the clients make a GET request, they will be able to see this documentation page

Data Params If making a POST request, the header should contain a Content-Type header that is set to application/json
Example:
{
	"CarID": [integers],
	"Code": [strings],
	"Value": [integers]
}

							
Detalied Example:
{
        "CarID": [1,1,1,1,2,3,4],
        "Code": ["00", "0F", "2B", "1E", "08", "11", "FF"],
        "Value": [73, 65, 8, -10, 100, 145, 0]
}
							
Success Response The server processes each pair (CarID, Code, Value) and tries to register a new entry in the database.
Error Response The POST request will be automatically dropped if the headers do not contain {"Content-Type": "application/json"}. In this case, the client will receive a JSON response, whose format is detalied in the below example
Example:
{
        "status": "INVALID_HEADER"
        "status_code": "401"
        "description": "Please send a JSON object"
}

                                                        

Also, if there are inconsistencies (the sizes of the vectors that are received are not equal), the POST request will be automatically dropped
Example:
{
        "status": "BAD_REQUEST"
        "status_code": "400"
        "description": "Inconsistent data - request dropped"
}

                                                        
Sample Call A sample call to the endpoint in a runnable format (Python).
import requests
import json
from urllib.request import urlopen

url = 'http://app1.westeurope.cloudapp.azure.com/upload/'
post_fields = { 'CarID': [1,2,3,4], 'Code': ['07', '08', '0B', 'FF'], 'Value': [12, 70, 13, 400] }

request = requests.post(url, data=json.dumps(post_fields), headers={'Content-Type': 'application/json'})
data = json.loads(request.text)
print(data)

						
Enabled Codes {% for index, row in df.iterrows %} {% endfor %}
Code Description DateAdded Units
{{ row.3 }} {{ row.6 }} {{ row.7 }} {{ row.10 }}