How to set foreign keys via API?

Dear all,

is there any documentation on how to set foreign keys via the API? Say, I want to set the ipaddress with id=24 as gateway on the network with id=415. I tried this:

curl -svv -X PATCH -F 'type=application/json' -H 'Authorization: Token <token>' -d '{"gateway": 24 }' http://ralph:8000/api/networks/415/

but obviously it does not work that way. Until now I only managed to set the gateway via the web interface.

Any ideas?

Thanks,
Andreas

Dear Andreas,
from the OPTIONS output of curl applied to the respective node, you can infer that “gateway” is a read-only value:
“gateway”: {
“type”: “nested object”,
“required”: false,
“read_only”: true,
“label”: “Gateway”,

I think you should(Note, that I never did this…) try to set this via a variable at the /api/ipaddresses/ node.

Dear Captain,

Thanks for your reply!

I tried to set it via the the /api/ipaddresses/ node. However, it is actually just a boolean which can be set {"is_gateway":true}. It is set for this particular ip but it does not show up as gateway for the network. Should there be some magic involved that does not work in this case?

As I managed to set the network’s gateway address via the web interface, I wonder how I can determine what the web interface actually does?

Thanks again,
Andreas

It seems like it’s a bug - I’m working on a fix.