How to receive a JsonObject by parameter in web services

PablogrindPablogrind Member Posts: 13
Hi, I try to create a web service in BC that receives this structure
curl --request POST \
  --url 'https://api.businesscentral.dynamics.com/v2.0/XXXXXXXXXXXXXXXXXXXX/Testing/ODataV4/Test_CreatePurchase?company='XXXXXXXXX\''' \
  --header 'Content-Type: application/json' \
  --data '{
	"_Header": "00007180",
	"_Lines": [
		{
			"Quantity": 12,
			"Amount": 1000
		},
		{
			"Quantity": 10,
			"Amount": 2000
		}
	]
}'

with this codeunit
procedure CreatePurchase(_Header: Code[20]; _Lines: JsonObject): Text .......................


but I get an error, with what type of data could handle the _Lines parameter

Best Answer

  • JJMcJJMc Member Posts: 60
    edited 2022-03-05 Answer ✓
    You can't pass Json variables from WS to a Procedure in BC. In BC you must receive this parameters as Text, and then parse them to a JsonToken and resolve them in BC

Answers

  • JJMcJJMc Member Posts: 60
    edited 2022-03-05 Answer ✓
    You can't pass Json variables from WS to a Procedure in BC. In BC you must receive this parameters as Text, and then parse them to a JsonToken and resolve them in BC
  • PablogrindPablogrind Member Posts: 13
    thanks
Sign In or Register to comment.