This message was deleted.
# suitescript
s
This message was deleted.
c
https://graphql.braintreepayments.com/explorer/ I hate screenshots of code, but this works
message has been deleted
s
yes, it worked on Braintree API explorer but not in suite script. Any idea?
c
No idea, as you haven't shared any code
My query above is not like yours
Also, dump the full
createCustMutation
to make sure it's ok
Actually, I have no idea what you're doing with the objects etc, doesn't seem to make sense. What's
variables
for, just for a start? You don't use it
s
variables is a key that we use in graphql API request JSON
@battk Any idea?
b
post your data to an echo service like https://httpbin.org/
i dont think your body is json
s
The JSON that i mentioned in my question is the request body and it is created by script. When i test this request body in postman, it is working properly but not in suite script
b
use an echo service
s
Yes i am trying
Sorry, don't how to test in httpbin. I tried but didn't find the way to test
b
log the response body
s
When i open the link 'https://httpbin.org/post' getting the msg The method is not allowed for the requested URL.
b
browsers open urls using GET
https://httpbin.org/post only works for POST
ill let you guess what path to use for a GET
s
https://httpbin.org/get, it opens but i still don't understand how to test post function. I'm sorry
b
Copy code
var response = <http://https.post|https.post>({
  url: url,
  body: body,
  headers: headers,
});
change the url to post data to httpbin instead
log the response body
s
Ok let me try
Here is the rseposne { "args": {}, "data": "variables=&query=%27mutation+createCustomer%28%24email%3A+String%2C%24firstName%3A+%7BcreateCustomer%28input%3A+%7Bcustomer%3A+%7Bemail%3A+%24email%2CfirstName%3A+%24firstName%2ClastName%3A+%24lastName%2CphoneNumber%3A+%24phoneNumber%7D%7D%29+%7Bcustomer+%7Bid+legacyId%7D%7D%7D%27", "files": {}, "form": {}, "headers": { "Accept": "application/json", "Accept-Encoding": "gzip, deflate", "Content-Length": "342", "Content-Type": "application/json", "Host": "httpbin.org", "User-Agent": "NetSuite/2021.1 (SuiteScript)", "X-Amzn-Trace-Id": "1-6139edd8-63c029603e3af6d8ff7jz78ff3" }, "json": null, "origin": "167.216.131.180", "url": "https://httpbin.org/post" }
Not sure if i did it correctly😨
b
data is what your request body looks like
specifically, thats not json'
s
Yes, that's the issue.
Thank you so much for your guidance
Appreciate your help
But not sure why i was able to successfully beautify the request body in https://codebeautify.org/jsonviewer
b
variables=&query=%27mutation+createCustomer%28%24email%3A+String%2C%24firstName%3A+String%2C%24lastName%3A+String%2C%24phoneNumber%3A+String%29+%7BcreateCustomer%28input%3A+%7Bcustomer%3A+%7Bemail%3A+%24email%2CfirstName%3A+%24firstName%2ClastName%3A+%24lastName%2CphoneNumber%3A+%24phoneNumber%7D%7D%29+%7Bcustomer+%7Bid+legacyId%7D%7D%7D%27
is not json
its the encoding used by a form post, which is base on percent encoding
s
yes you are right, it is not JSON. But in my code, i stringify the request string and print the log and then i beautify it in code beautifier.
b
netsuite encodes the body of https.post using that encoding when the body is a javascript object
s
got it, thank you