Skip to main content

How to call an external weebhook with script / button?


Forum|alt.badge.img+7
  • Known Participant
  • 27 replies

Hello, i am trying to create users on Softr solution with their api script, i tried to put in a script on airtable but it show me an error.
I need to integrate records data (name, email etc.)

here is the code :

curl --request POST 'https://studio-api.softr.io/v1/api/users' \
--header 'Softr-Api-Key: F00xq00gpZf8TLCFYsbsSa7CzRO' \
--header 'Softr-Domain: app.softr.app' \
--header 'Content-Type: application/json' \
--data-raw '{
  "full_name": "NAME-FIELD",
  "email": "EMAIL-FIELD",
  "password": "12345678",
  "generate_magic_link":true
}'```

4 replies

kuovonne
Forum|alt.badge.img+27
  • Brainy
  • 6002 replies
  • April 5, 2022

It looks like you just publicly posted an API key. If this was your actual API key (versus a dummy documentation key) I recommend that you change it immediately.

As for calling a webhook from scripting, you need to change the CURL request to a JavaScript fetch request. It is a very different format. You can Google how to convert a CURL request to a fetch request.


Forum|alt.badge.img+7
  • Author
  • Known Participant
  • 27 replies
  • April 5, 2022

thank you
no its an edited api key, i add some caracters :slightly_smiling_face:

i used a website that convert to fetch (cURL to Fetch)

fetch("https://studio-api.softr.io/v1/api/users", {
  headers: {
    "Content-Type": "application/json",
    "Softr-Api-Key": "F00xq00gpZf8TLCFYsbsSa7CzRO",
    "Softr-Domain": "app.softr.app"
  },
  method: "POST"
})```

i can see that the parameters are gone :/
i need to parse those data from every record 

any advice ?

JonathanBowen
Forum|alt.badge.img+18
JAN11 wrote:

thank you
no its an edited api key, i add some caracters :slightly_smiling_face:

i used a website that convert to fetch (cURL to Fetch)

fetch("https://studio-api.softr.io/v1/api/users", {
  headers: {
    "Content-Type": "application/json",
    "Softr-Api-Key": "F00xq00gpZf8TLCFYsbsSa7CzRO",
    "Softr-Domain": "app.softr.app"
  },
  method: "POST"
})```

i can see that the parameters are gone :/
i need to parse those data from every record 

any advice ?

@JAN - have a look at this post - it has a similar goal and gives you the fetch pattern you need. You need an additional attribute on the fetch options for body (which contains the data you want to POST to the API.


PaulHinton
Forum|alt.badge.img+3
  • New Participant
  • 1 reply
  • September 3, 2023

For those still looking for the Javascript code.... Keep in mind you will need to setup the input variables as they correspond to your table data. Also, you will need to replace things like {APIKey} with your API key from Softr, and {Softr Domain} with your Softr domain example would be "appname.softr.app".

 

let inputConfig = input.config(); let apiUrl = `https://studio-api.softr.io/v1/api/users`; let requestOptions = { method: 'POST', headers: { 'Softr-Api-Key': '{APIKey}', 'Softr-Domain': '{Softr Domain}', 'Content-Type': 'application/json' }, body: JSON.stringify({ 'full_name': inputConfig.full_name, 'email': inputConfig.user_email, 'password': inputConfig.user_password, 'generate_magic_link': true }) }; //console.log(requestOptions); let response = await fetch(apiUrl, requestOptions); //console.log(await response.text());