Skip to main content

Hello I have some JS code below related to the API of an app we use at work.

 

I am trying to get the to numbers section below to return the input data in the screen shot. I have no idea how to write JS but any help or ideas to get this to be correct would be great. 

 

In the actual JS code from the API docs I was returning this and on testing it worked.

 

"to_numbers": s"+15555555555"],

 

I can’t however figure out how to pull the input data

 

 

import requests

url = "https://dialpad.com/api/v2/sms"

payload = {
"infer_country_code": False,
"to_numbers": return {'phone': input_data p'phone']},
"text": "test message",
"user_id": sID NUMBER REMOVED BY MODERATOR]
}
headers = {
"accept": "application/json",
"content-type": "application/json",
"authorization": "Bearer API KEY REMOVED BY MODERATOR]"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

 

This post has been edited by a moderator to remove personal information. Please remember that this is a public forum and to remove any sensitive information prior to posting.

Assuming the number has to be surrounded by square brackets:

At the top, write:

let phone = '["' + inputData.phone + '"]';

then, in the API call, write:

"to_numbers": phone,

 


That didn’t quite work. But it made me realize what the Zapier were instructions were saying. Updated it and this seemed to work in the test.

return {'phone': input_data a'phone']}

import requests

url = "https://dialpad.com/api/v2/sms"

payload = {
"infer_country_code": False,
"to_numbers": 'phone',
"text": "test message",
"user_id": :ID NUMBER REMOVED BY MODERATOR]

This post has been edited by a moderator to remove personal information. Please remember that this is a public forum and to remove any sensitive information prior to posting.


@Dan_GRHF Ah, looks like you were actually using Python, not JS. Didn’t catch that on my first read through, since I was hyper focused on the JS solution. Glad it worked in the end :)


my mistake sorry about that. Probably because I am not a coder and was just copying what the api docs gave me I must not have realized it.