Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhostkeeper <rubend@tutanota.com>2021-10-27 14:16:39 +0300
committerGhostkeeper <rubend@tutanota.com>2021-10-27 14:16:39 +0300
commit1c6ad019a3e9fd35999edc838b1296701ae358dc (patch)
tree9f5aa1108e183e65b5ecb95573c9e048162cecbb /cura/PrinterOutput
parent8bd6fe7c2b3072a99c33e6a7d4390482b7bb7b36 (diff)
Response data is contained in sub-field 'data'
The entire response is contained in a lone 'data' field in the response. Why this is necessary I don't know, because indeed everything the server can tell us is data so everything would be in a 'data' field. But that's how the API reacts so that's how we'll have to parse it. Contributes to issue CURA-8609.
Diffstat (limited to 'cura/PrinterOutput')
-rw-r--r--cura/PrinterOutput/UploadMaterialsJob.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/cura/PrinterOutput/UploadMaterialsJob.py b/cura/PrinterOutput/UploadMaterialsJob.py
index 99484a4430..73352258d4 100644
--- a/cura/PrinterOutput/UploadMaterialsJob.py
+++ b/cura/PrinterOutput/UploadMaterialsJob.py
@@ -133,17 +133,21 @@ class UploadMaterialsJob(Job):
Logger.error(f"Invalid response to material upload request. Could not parse JSON data.")
self.failed(UploadMaterialsError(catalog.i18nc("@text:error", "The response from Digital Factory appears to be corrupted.")))
return
- if "upload_url" not in response_data:
+ if "data" not in response_data:
+ Logger.error(f"Invalid response to material upload request: Missing 'data' field that contains the entire response.")
+ self.failed(UploadMaterialsError(catalog.i18nc("@text:error", "The response from Digital Factory is missing important information.")))
+ return
+ if "upload_url" not in response_data["data"]:
Logger.error(f"Invalid response to material upload request: Missing 'upload_url' field to upload archive to.")
self.failed(UploadMaterialsError(catalog.i18nc("@text:error", "The response from Digital Factory is missing important information.")))
return
- if "material_profile_id" not in response_data:
+ if "material_profile_id" not in response_data["data"]:
Logger.error(f"Invalid response to material upload request: Missing 'material_profile_id' to communicate about the materials with the server.")
self.failed(UploadMaterialsError(catalog.i18nc("@text:error", "The response from Digital Factory is missing important information.")))
return
- upload_url = response_data["upload_url"]
- self._archive_remote_id = response_data["material_profile_id"]
+ upload_url = response_data["data"]["upload_url"]
+ self._archive_remote_id = response_data["data"]["material_profile_id"]
try:
with open(cast(str, self._archive_filename), "rb") as f:
file_data = f.read()