Jump to content
Froxlor Forum
  • 0

Issue while using API to create an eMail Address


cscholz

Question

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

6 answers to this question

Recommended Posts

  • 0

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

  • 0

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

  • 0

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...