Hi Deep! The reason you are getting this error is because an attachment for this beacon already exists. Take a look at https://cloud.estimote.com/docs/#api-Attachments-CreateAttachment you are getting an error like 400_Bad_Request Attachment for identifier already exists
I have just try to create attachements for my another fresh beacon & its working fine. But below is the scenario in which estimote curl api to create attachments not working.
Step 1 : Create attachemets using curl api for fresh or new beacon.(working fine)
Step 2: Now remove attachments from estimote cloud login under edit settings of that beacon. (removed successfully)
Step 3: Again try to Create attachemets using curl api for the same beacon(means step 1 repeat) – here i got error everytime.
Error:
code 400 message "Unique constraint violation" name "EstimoteError"
So conclusion is that for the first time i can create attachments for particular beacon but if i remove that attachments from estimote cloud login for that beacon , I am not able to create attachments again for that beacon.
Can you please follow the above steps to raise an issue so that we can sort out asap.
But here I am confused that if by mistakenly I have removed attachments from Cloud UI, that means after that I will not able to create attachments in future for that beacon using curl api.
so is that true way to achieve functionality technically.
One more thing if i wanted to delete attachments using curl api than where can I get ATTACHMENT_ID to delete it.
In your case the request should look like this: https://cloud.estimote.com/v3/attachments?identifiers=YOUR_DEVICE_IDENTIFIER
Then in response you should find your Attachment, it’s id is the ATTACHMENT_ID you need.
@JGrzesik Ok thanks , I got ATTACHMENT_ID as per your suggestion.
But I am still confusing what happens if by someone or by me mistakenly remove attachments from cloud UI than which steps I have to perform to make it working again to add attachments using curl api.
Because as per your understanding if I removed attachments by mistakenly from estimote cloud UI than i have to compulsory make call of delete or update api to create attachments again.
Please suggest best way to create attachments if i removed it from estimote cloud UI also with miniumum line of code.
If you are trying to assign the same key-value pairs to multiple beacons you select multiple beacons in Estimote Cloud, press “Edit” and use attachment tab to enter keys and values and then press “Save Changes”. This way you would update existing attachments and create new ones if some are missing. Using this method you can create hundreds of attachments with just a few clicks.
Another way, if you want to use CURL would be to use this endpoint https://cloud.estimote.com/docs/#api-Attachments-GetAttachments without any query parameters it should return a list of all attachments in your account, to detect any attachments that are empty ("payload": {}).
Manually delete them using the delete endpoint. After that cleanup your script should work.