Apr 05, 2022 04:34 AM
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
}'```
Apr 05, 2022 07:37 AM
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.
Apr 05, 2022 08:01 AM
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 ?
Apr 09, 2022 06:03 AM
@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.
Sep 03, 2023 11:58 AM
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());