November 12, 20232 yr 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?
November 12, 20232 yr 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
November 12, 20232 yr Author 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
November 12, 20232 yr So by your question I guess it's not working? Why waste time for a meta question ... just post the error/response
November 12, 20232 yr Author Error is the same. "Requested parameter \"email_part\" could not be found for \"Emails:add\""
November 12, 20232 yr 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" ] ]
November 12, 20232 yr Author 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
Create an account or sign in to comment