0

I'm trying to build a vcard using vobject python library. The server uses multiple phone types like this:

TEL;TYPE="HOME","VOICE":111111111
TEL;TYPE="WORK","VOICE":4444444444

So I'm trying to do the same.

vcard_phone = vcard.add('tel')
vcard_phone.value = "111111111"
vcard_phone.type_param = ["HOME","VOICE"]

But this results to:

TEL;TYPE=WORK,VOICE:4444444444

I think that this is considered to be one value (there are no quotes).

I also tried:

vcard_phone.type_param = '"HOME","VOICE"'

which raises an exception:

vobject.base.VObjectError: "Double quotes aren't allowed in parameter values."

I couldn't find anything regarding this in the docs. How to do that?

Milano
  • 18,048
  • 37
  • 153
  • 353
  • A vCard phone number can have multiple types attached. I think what you want should look like this: ``` vcard_phone = vcard.add('tel') vcard_phone.value = "111111111" vcard_phone.type_param = "HOME" vcard_phone = vcard.add('tel') vcard_phone.value = "111111112" vcard_phone.type_param = "FAX" ``` And no, the values definitely do not have to be quoted, and I suspect it is even illegal to do so, not 100% sure. You'd need to check the vCard RFC. (custom types on Apple platforms are done using labels, BTW, not actual TYPE values) – hnh Feb 08 '22 at 14:18
  • @hnh Thanks, so that means vObject works correctly but there is a bug in nextcloud as they accept this format: TEL;TYPE="WORK","VOICE":4444444444. If I use it without quotes, the phone type looks like this: `WORK,VOICE` – Milano Feb 08 '22 at 15:07
  • I don't use the php cloud, so I can't comment on this. It is quite common though, that clients don't deal with multi or custom types well, e.g. as mentioned Apple software uses an entirely different mechanism for typing. Here is the relevant RFC for type: https://datatracker.ietf.org/doc/html/rfc6350#section-5.6 – hnh Feb 08 '22 at 16:14

0 Answers0