profile
viewpoint

Ask questionsID in Location Header

Hi there,

I want to create QBoxMail inboxes via terraform and the API looks like this

/**
 * Create a new email account (info@hello2.com)
 */

curl -v \
    -H "Content-Type: application/json" \
    -H "X-Api-Token: 3u2eIGWX2oN_Z2TRxZOp5Si8hzrDF6vpyxYcdWAX-WUnbBroqNmphw9PUBbGNolP" \
    -X POST -d '{
        "name":"info",
        "firstname": "info",
        "password":"Qwertyuiop0",
        "password_confirmation":"Qwertyuiop0" }' \
    https://api.qboxmail.com/api/domains/D727264119/email_accounts

> POST /api/domains/D727264119/email_accounts HTTP/1.1
> Host: api.qboxmail.com
> User-Agent: curl/7.51.0
> Accept: */*
> Content-Type: application/json
> X-Api-Token: 3u2eIGWX2oN_Z2TRxZOp5Si8hzrDF6vpyxYcdWAX-WUnbBroqNmphw9PUBbGNolP
> Content-Length: 108

< HTTP/1.1 201 Created
< Location: https://api.qboxmail.com/domains/D727264119/email_accounts/EA03350967
< Content-Type: application/json
< Content-Length: 28
< Etag: W/"a0d00fe50a65a8b47780d2dce5029fb4"
< Cache-Control: max-age=0, private, must-revalidate
< X-Request-Id: e9032d55-3d8a-4c5f-99d9-af18bb44c015
< X-Runtime: 0.775738
< Vary: Origin
< Server: WEBrick/1.3.1 (Ruby/2.3.3/2016-11-21)
< Date: Tue, 29 Nov 2016 08:38:30 GMT
< Connection: Keep-Alive

Body:
{
    "message": "risorsa creata"
}

The created id EA03350967 can be found in the Location header, not the body

Location: https://api.qboxmail.com/domains/D727264119/email_accounts/EA03350967

Is it possible with the current provider to extract this id?

Cheers, Dennis

PS: QBoxMail API https://www.qboxmail.com/api-doc/#api-Emails-PostEmails

Mastercard/terraform-provider-restapi

Answer questions dennis-tra

Turns out the documentation is out of date and the API indeed returns a field resource_created that contains an ID.

useful!
source:https://uonfu.com/
answerer
Dennis Trautwein dennis-tra OriginStamp AG Kreuzlingen, Switzerland https://dtrautwein.eu BSc./MSc. in extraterrestrial/solid state physics | iOS/WebDev WellingtonNZ/MelbourneAU | BackendDev@freiheit.com HamburgGER | Dev@OriginStamp CH
Github User Rank List