Does anyone have experience using the SuiteTalk RE...
# general
j
Does anyone have experience using the SuiteTalk REST API to transform a PO to a Vendor Bill? I'd like to set field values of the Vendor Bill, but get "Invalid Content" errors no matter how I try to format the JSON in the request.
b
what does your request body look like
j
I had tried a few ways, based on how I had sent other post requests
Copy code
transform_json = {
	"vendorBill" : {
		"fields" : {
			"dueDate" : "8/26/2022"
		}
	}
}
Copy code
transform_json = {
	"fields" : {
		"dueDate" : "8/26/2022"
	}
}
Copy code
transform_json = {
	"dueDate" : "8/26/2022",
}
Copy code
transform_json = {
	"vendorBill" : {
		"fields" : {
			"dueDate" : "8/26/2022"
		}
	}
}
Copy code
transform_json = {
	"dueDate" : "2022-08-26",
}
b
log the request body that you are sending
you can use an echo service like https://httpbin.org/ if you dont know how
j
I've been using this python library that puts a lot of the request together for me so I'm not sure if I can get the whole request body.
Putting together the authentication to make requests was another thing I couldn't find good docs on
b
send the post to httpbin instead
the response will contain the request body
j
sorry, I've never used httpbin before. Do I need to put together an authentication header or just send the transform_json I'm trying to use in a post to httpbin.org?
b
change the url you are using to http://httpbin.org/post
log the response body you receive
if you are extra cautious, you wouldnt send the authentication details, but TBA is resistant to replay attacks
so you can leave it if you want
j
okay, thanks. I just sent it the transform_json and the text of the response is:
Copy code
{
  "args": {},
  "data": "\"{\\\"vendorBill\\\": {\\\"fields\\\": {\\\"dueDate\\\": \\\"8/26/2022\\\"}}}\"",
  "files": {},
  "form": {},
  "headers": {
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate",
    "Content-Length": "62",
    "Content-Type": "application/json",
    "Host": "<http://httpbin.org|httpbin.org>",
    "User-Agent": "python-requests/2.22.0",
    "X-Amzn-Trace-Id": "Root=1-62ebee35-4bac7e0c124ed7af5c593306"
  },
  "json": "{\"vendorBill\": {\"fields\": {\"dueDate\": \"8/26/2022\"}}}",
  "origin": "24.168.217.64",
  "url": "<http://httpbin.org/post>"
}
and that's just from
Copy code
p = <http://requests.post|requests.post>("<http://httpbin.org/post>", json=transform_json)
print (p.text)
b
you are sending the post wrong
your library is sending it as a json string
it looks like your objects was stringified twice
you are posting
Copy code
"{\"vendorBill\": {\"fields\": {\"dueDate\": \"8/26/2022\"}}}"
instead of
Copy code
{
  "vendorBill": {
    "fields": {
      "dueDate": "8/26/2022"
    }
  }
}
j
I sure was. That was it!
Thank you so much for helping me out and pointing me towards httpbin.