{"action":"opened","issue":{"url":"https://api.github.com/repos/textmagic/textmagic-rest-ruby/issues/5","labels_url":"https://api.github.com/repos/textmagic/textmagic-rest-ruby/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/textmagic/textmagic-rest-ruby/issues/5/comments","events_url":"https://api.github.com/repos/textmagic/textmagic-rest-ruby/issues/5/events","html_url":"https://github.com/textmagic/textmagic-rest-ruby/issues/5","id":107370736,"number":5,"title":"Should receive and http 409 when posting a duplicate contact.","user":{"login":"matthewcummings","id":1292655,"avatar_url":"https://avatars.githubusercontent.com/u/1292655?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewcummings","html_url":"https://github.com/matthewcummings","followers_url":"https://api.github.com/users/matthewcummings/followers","following_url":"https://api.github.com/users/matthewcummings/following{/other_user}","gists_url":"https://api.github.com/users/matthewcummings/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewcummings/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewcummings/subscriptions","organizations_url":"https://api.github.com/users/matthewcummings/orgs","repos_url":"https://api.github.com/users/matthewcummings/repos","events_url":"https://api.github.com/users/matthewcummings/events{/privacy}","received_events_url":"https://api.github.com/users/matthewcummings/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-20T03:53:43Z","updated_at":"2015-09-20T03:53:43Z","closed_at":null,"body":"This is a bug in the underlying REST API, not the Ruby wrapper.  Also, I suspect that it may occur with other entities, not just contacts.  If that turns out to be the case, I will update this issue or create a new one(s).\r\n\r\nWhen you create a new contact using the phone number of an existing contact, the response is an HTTP 400 with this payload\r\n```\r\n\"{\"code\":400,\"message\":\"Validation Failed\",\"errors\":{\"fields\":{\"phone\":[\"Phone number already exists in your contacts.\"]}}}\"\r\n```\r\nInstead, the response code should be a 409.  Also, it would be nice if the phone number were included in the payload.  It would make it easier for the user to track down the issue.\r\n\r\nNot a serious issue, nonetheless see this SO post for more details about the expected REST results for a case like this: http://stackoverflow.com/questions/3290182/rest-http-status-codes-for-failed-validation-or-invalid-duplicate\r\n"}}