
Scenario 01 : Slicing a Workspace file
This scenario shows you how to slice a Workspace file using our API from start to finish.
Step 1: Upload a file
POST /upload/{fileType}/{fileName}
In order to slice a file, first you need to upload it.
HTTP Request
POST https://realvisiononline.azure-api.net/v1/upload/WS/benchy.json HTTP/1.1
Content-Type: application/octet-stream
Cache-Control: no-cache
Ocp-Apim-Subscription-Key: [YOUR_SUBSCRIPTION_KEY_HERE]
[ benchy.json ]
HTTP Response
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
date: Thu, 17 Dec 2020 10:52:18 GMT
transfer-encoding: chunked
vary: Origin
{
"fileId": "ca489322-8867-48aa-baaf-cbe72bcc0fbd",
"fileName": "benchy.json",
"type": "WS"
}
Step 2: Start a slicing task
POST /ws/tasks/
Use the fileId
you got back from the previous request to slice the file you uploaded. This request only starts a slicing task and returns a taskId
which you will need later on.
HTTP Request
POST https://realvisiononline.azure-api.net/v1/ws/tasks HTTP/1.1
Content-Type: application/json
Cache-Control: no-cache
Ocp-Apim-Subscription-Key: [YOUR_SUBSCRIPTION_KEY_HERE]
{
"files":[
{
"fileId": "ca489322-8867-48aa-baaf-cbe72bcc0fbd",
"type": "WS",
"fileName": "benchy.json"
}
],
"settings":{
"printerModel": "Creality Ender 3",
"supportType": "n",
"filamentPresetName": "Createch_PLA"
}
}
HTTP Response
HTTP/1.1 200 OK
content-encoding: gzip
content-type: application/json; charset=utf-8
date: Thu,17Dec202010:41:37 GMT
transfer-encoding: chunked
vary: Accept-Encoding, Origin
{
"taskId": "fb9931af-012a-4c83-b3e5-f63c7ea211e0",
"queueDate": "2020-12-17T10:41:34.7919292Z",
"startDate": "0001-01-01T00:00:00",
"endDate": "0001-01-01T00:00:00",
"status": "queued",
"files":[
{
"fileId": "2986fa45-4d91-41a4-a0d1-6584512a85db",
"fileName": "benchy.json",
"type": "WS"
}
],
"settings":{
"printerModel": "Creality Ender 3",
"supportType": "n",
"filamentPresetName": "Createch_PLA"
},
"progress": 0
}
Step 3: Check the status of the slicing task
POST /ws/tasks/{taskId}
Use the taskId
you got back from the previous request to check the status of the slicing task you started. The response will contain a status property which has four possible values:
queued: means that the slicing task has been added to a wait queue. You'll be able to see a
queueDate
for when it has been queued.
started: means that the slicing task has been picked up by one of our slicing servers and is being processed. The response will have a
startDate
property for when the slicing actually started.running: It means that the slicing task processing is done and slicing is running. In this case, the response will have a
progress
property that will tell you how far along is the slicing task is.finished: means the slicing task is finished and you're free to download the output file which will be either a GCode or an FCode file. When the status is finished, the response will also have two additional properties. So, instead of
progress
, it will have theoutput
andinfo
properties. Theoutput
has information about the output file, and theinfo
property has information about the print (estimated filament length, weight and time).failed: means the slicing task failed for some reason. In this case, the response will have an
error
property which will contain details about the error that happened.cancelled: means you cancelled the slicing task.
For now, we're going to assume the slicing task is finished at the time of the request. You'll notice in the samples below that the response has two additional properties: info
and output
. Save theoutput -> outputId
because we will be using in the next request.
HTTP Request
GET https://realvisiononline.azure-api.net/v1/ws/tasks/b596ac31-a782-4776-99cb-11aa2fcb534e HTTP/1.1
Cache-Control: no-cache
Ocp-Apim-Subscription-Key: [YOUR_SUBSCRIPTION_KEY_HERE]
HTTP Response
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
date: Thu,17Dec202010:54:21 GMT
transfer-encoding: chunked
vary: Origin
{
"taskId": "b596ac31-a782-4776-99cb-11aa2fcb534e",
"queueDate": "2020-12-17T04:45:10.860Z",
"startDate": "2020-12-17T04:45:12.892Z",
"endDate": "2020-12-17T04:45:14.661Z",
"status": "finished",
"files": [
{
"fileId": "7f6b4cdc-d502-4197-9ae1-970ebde7e2b4",
"fileName": "benchy.json",
"type":"WS"
}
],
"settings":{
"printerModel": "Creality Ender 3",
"supportType":"n",
"filamentPresetName":"CreaTECH_PLA"
},
"progress": 1,
"info": {
"time": "0:19:40",
"length": "1.69meter(s)",
"weight": "5gram(s)"
},
"output": {
"outputName": "benchy.gcode",
"outputId":"cd5b659e-3ff3-4fb4-92a2-46136072ad1a",
"taskId":"b596ac31-a782-4776-99cb-11aa2fcb534e",
"fileId":"cd5b659e-3ff3-4fb4-92a2-46136072ad1a",
"format":"GCODE"
}
}
Step 4: Download output file (FCode/GCode)
GET /output/{outputId}/download
Use the outputId
you got back from the previous request to download the final file.
HTTP Request
GET https://realvisiononline.azure-api.net/v1/output/cd5b659e-3ff3-4fb4-92a2-46136072ad1a/download HTTP/1.1
Cache-Control: no-cache
Ocp-Apim-Subscription-Key: [YOUR_SUBSCRIPTION_KEY_HERE]
HTTP Response
HTTP/1.1 200 OK
content-disposition: attachment; filename=benchy.gcode; filename*=UTF-8''benchy.gcode
content-type: application/octet-stream date: Thu, 17 Dec 2020 11:04:48 GMT
vary: Origin
; G-Code flavour: Marlin
; Print time: 0:19:40
; Filament used: 1.69 meter(s)
; Estimated weight: 5 gram(s)
...
The response above is a truncated gcode
file just for example purposes.
