cscholz Posted November 12, 2023 Posted November 12, 2023 Hi, I'm strugeling on my first steps with the API. I've read the documentation and using curl to ensure that the API calls are correct. bash variables are set and working. Quote FROXLOR_API_KEY=as471... FROXLOR_API_SECRET=kp471... AUTH=$(echo -ne "$FROXLOR_API_KEY:$FROXLOR_API_SECRET" | base64 --wrap 0) What works is the readout via API using the example from the documentation: Quote curl -v \ --header "Content-Type: application/json" \ --header "Authorization: Basic $AUTH" \ --request POST \ --data '{"command":"Froxlor.listFunctions"}' \ https://domain.tld/api.php What does not work is the creation of an email address. Quote curl -v \ --header "Content-Type: application/json" \ --header "Authorization: Basic $AUTH" \ --request POST \ --data '{"command":"Emails.add","email_part": "test86","domain": "domain.tld"}' https://domain.tld/api.php [...] The API tells me: Requested parameter \"email_part\" could not be found for \"Emails:add\"" What am I doing wrong?
0 d00p Posted November 12, 2023 Posted November 12, 2023 simple, see https://docs.froxlor.org/latest/api-guide#_2-request-structure-layout You have a "command" part but your parameters are not in the "params" part
0 cscholz Posted November 12, 2023 Author Posted November 12, 2023 Thanks for the quick reply; you're right. Sorry for my dump question but shoulnd this be correct? Quote curl -v \ --header "Content-Type: application/json" \ --header "Authorization: Basic $AUTH" \ --request POST \ --data '{"command": "Emails.add","params":[{"email_part":"test86","domain":"domain.tld"}]}' https://domain.tld/api.php
0 d00p Posted November 12, 2023 Posted November 12, 2023 So by your question I guess it's not working? Why waste time for a meta question ... just post the error/response
0 cscholz Posted November 12, 2023 Author Posted November 12, 2023 Error is the same. "Requested parameter \"email_part\" could not be found for \"Emails:add\""
0 d00p Posted November 12, 2023 Posted November 12, 2023 Your JSON array is wrong, instead of "params":[{"email_part":"test86","domain":"domain.tld"}] just use "params":{"email_part":"test86","domain":"domain.tld"} Difference (as php would view it): [ "command" => "Emails.add", "params" => [ [ "email_part" => "test86", "domain" => "domain.tld" ] ] ] and the correct syntax: [ "command" => "Emails.add", "params" => [ "email_part" => "test86", "domain" => "domain.tld" ] ]
0 cscholz Posted November 12, 2023 Author Posted November 12, 2023 Okay. Got it, thanks! Three API calls via curl as further examples from my test run for all readers of the forum Create eMail Quote curl -v \ --header "Content-Type: application/json" \ --header "Authorization: Basic $AUTH" \ --request POST \ --data '{"command": "Emails.add","params":{"email_part":"test123","domain":"mydomain.com"}}' https://froxlor.mydomain.com/api.php Create Forward Quote curl -v \ --header "Content-Type: application/json" \ --header "Authorization: Basic $AUTH" \ --request POST \ --data '{"command": "EmailForwarders.add","params":{"emailaddr":"test123@mydomain.com","destination":"recipient@mydomain.com"}}' https://froxlor.mydomain.com/api.php Delete eMail Quote curl -v \ --header "Content-Type: application/json" \ --header "Authorization: Basic $AUTH" \ --request POST \ --data '{"command": "Emails.delete","params":{"emailaddr":"test123@mydomain.com"}}' https://froxlor.mydomain.com/api.php BR Christian
Question
cscholz
Hi,
I'm strugeling on my first steps with the API. I've read the documentation and using curl to ensure that the API calls are correct.
bash variables are set and working.
What works is the readout via API using the example from the documentation:
What does not work is the creation of an email address.
The API tells me: Requested parameter \"email_part\" could not be found for \"Emails:add\""
What am I doing wrong?
6 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now