Carddav applescript update

HI All

Im new to applescript, and im having a problem. Im trying to add a contact to the contacts app on mountain lion server. I have successfully added a contact to the local machine, however i wish to add a contact to the carddav group. My end goal is to export all my contacts from active directory (done via another app, to csv) and import them to the contacts app. Using Java, i can import my csv file and then executing applescript to add the contact to Contacts app.

I have tried creating a group in my carddav account called “TestGroup” and the code i used was

add thePerson to group "TestGroup"

However i got an error message saying
Contacts got an error: You can only add a person to a group.

Once i can add the user below to Carddav directory, i can use Java to loop through the csv and insert all the users.

I have already tested this as working. So my issue is just adding a contact to the carddav directory.

The carddav directory is also hosted on the same machine.

Your help will be greatly appreciated.

My applescript so far is.


tell application "Contacts" 
set thePerson to make new person with properties{first name:"Joe", last name:"Bloe"} 
make new phone at end of phones of thePerson with properties{label:"mobile", value: "0422123456"}
make new email at end of emails of thePerson with properties{label:"Work", value: "test@test.com"}
save 
end tell

Model: iMac Mini (2013)
AppleScript: Latest
Browser: Safari 536.30.1
Operating System: Mac OS X (10.8)