How to create a contact via API/HTTP Request

Hi all, I am not sure if this is the correct category to post my issue.

I am really struggling since yesterday to add contacts into my nextcloud server via
n8n / API / http request

I would really appreciate if you guys can guide me on how to setup that.

Something like this:
make a post request to your nextcloud URL
include in the header ( username and password )
include in the body json field with the contact information.

Thanks

hi @kokoko welcome to the forum :handshake:

I have no working example but this API reference might be useful:

https://docs.nextcloud.com/server/latest/developer_manual/client_apis/index.html

I don’t see any contacts related methods right away… but maybe you are lucky.
additionally I’m under impression contacts are exposed through WebDAV - maybe you can access them this way…

Appreciate your reply. But sadly, nothing useful in NC documentation.

Is it even possible? I have spent long time trying to figure it out.

Just use webdav for example with a cURL request:

curl -u <USERNAME>:<PASSWORD> 'https://<NEXTCLOUD_URL>/remote.php/dav/addressbooks/users/<USERNAME>/<ADDRESSBOOKNAME>/12345678-1234-1234-1234-1234567890AB.vcf' -X PUT -H 'Depth: 0' -H 'Content-Type: text/vcard; charset=utf-8;' -H 'DNT: 1' \
--data-binary 'BEGIN:VCARD
VERSION:3.0
FN:Example Mister
UID:12345678-1234-1234-1234-1234567890AB
ADR;TYPE=HOME:;;Examplestreet 1;Examplecity;;12345;
TEL;TYPE=HOME,VOICE:123456789
EMAIL;TYPE=HOME:mister@example.com
END:VCARD'

As filename use the same UID as in the vcf and make sure to create different UIDs for different contacts.
Add more values to your liking according to RFC 6350

1 Like

Thank you so much. It worked well.

I wonder why they hide these info from documentation.

1 Like