cscholz Posted November 12 Share Posted November 12 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? Link to comment Share on other sites More sharing options...
0 d00p Posted November 12 Share Posted November 12 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 Link to comment Share on other sites More sharing options...
0 cscholz Posted November 12 Author Share Posted November 12 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 Link to comment Share on other sites More sharing options...
0 d00p Posted November 12 Share Posted November 12 So by your question I guess it's not working? Why waste time for a meta question ... just post the error/response Link to comment Share on other sites More sharing options...
0 cscholz Posted November 12 Author Share Posted November 12 Error is the same. "Requested parameter \"email_part\" could not be found for \"Emails:add\"" Link to comment Share on other sites More sharing options...
0 d00p Posted November 12 Share Posted November 12 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" ] ] Link to comment Share on other sites More sharing options...
0 cscholz Posted November 12 Author Share Posted November 12 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 Link to comment Share on other sites More sharing options...
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?
Link to comment
Share on other sites
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