Skip to content

Agent cannot parse json asset #477

Description

@robot-ranger

Unless Im doing it wrong, It looks like the agent is expecting xml for assets. I tried sending the following with a curl command:

{
	"TaskArchetype": {
		"assetId": "LoadCnc",
		"Priority": 2,
		"TaskType": "MATERIAL_LOAD",
		"Coordinator": {
			"collaboratorId": "cnc1",
			"CollaboratorType": "CNC"
		},
		"Collaborators": {
			"Collaborator": {
				"collaboratorId": "r1",
				"CollaboratorType": "ROBOT"
			}
		},
		"SubTaskRefs": [
			{
				"order": "1",
				"value": "OpenDoor"
			},
			{
				"order": "2",
				"value": "MoveIn"
			},
			{
				"order": "3",
				"value": "ReleasePart"
			},
			{
				"order": "4",
				"value": "CloseChuck"
			},
			{
				"order": "5",
				"value": "MoveOut"
			},
			{
				"order": "6",
				"value": "CloseDoor"
			}
		]
	}
}

curl -X POST "http://192.168.1.1:5000/asset/load-cnc-1?device=mxi_m001&type=TaskArchetype" -H "Content-Type: application/json" -d @load-cnc.json

but got:

<?xml version="1.0" encoding="UTF-8"?>
<MTConnectError xmlns:m="urn:mtconnect.org:MTConnectError:2.3"
	xmlns="urn:mtconnect.org:MTConnectError:2.3"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="urn:mtconnect.org:MTConnectError:2.3 /schemas/MTConnectError_2.3.xsd">
	<Header creationTime="2024-07-10T03:26:52Z" sender="0cfa26291d8b" instanceId="1720580135"
		version="2.3.0.16" deviceModelChangeTime="2024-07-10T02:55:35.142034Z" bufferSize="16384" />
	<Errors>
		<Error errorCode="INVALID_REQUEST">Could not parse Asset.</Error>
		<Error errorCode="INVALID_REQUEST">: Cannot parse asset</Error>
	</Errors>
</MTConnectError>

We had eliminated xml in favor of json response docs from the agent. Can we add json parser capability to cppagent's assets?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions