V8 API Account to Document Link

Hi

How to create an account to document link?

POST URL: /Api/V8/module/Accounts/{{ id }}/relationships
DATA:

{  
   "data":[  
      {  
				"type": "Documents",
				"id": "{{ id }}"
      }
   ]
}

RESPONSE:

{
  "errors": {
    "status": 400,
    "title": null,
    "detail": "The option \"0\" does not exist. Defined options are: \"id\", \"type\"."
  }
}

Any help would be appreciated.

Cheers
Steve

Hi,
it seems like you’re using the same variable for both Ids ( {{id}} ). Within the URL, you should provide the respective account id, within the json, you provide the document id.

1 Like

Sorry, my bad! I am actually using two different ID’s just my crap example :slight_smile:

Cheers
Steve

I guess your [ ] brackets are wrong :slight_smile:

Hi @Sheathy,

Welcome to the Community! :tada:

Quick tip for the forums you can surround top and bottom with ``` or inline on both sides with ` which produces code boxes and make it easier to read. I’ve updated your post to include these


So to add a document to the subpanel of and account (I.e relate them)

Post
/V8/module/Accounts/ID_OF_ACCOUNT_RECORD/relationships

Request Body

{
  "data": {
    "type": "Documents",
    "id": "ID_OF_DOCUMENT_RECORD"
  }
}

And you should get a response like this (Includes example IDs here)

{
    "meta": {
        "message": "Document with id eba910c5-cf4d-b31c-906c-5f9943cae193 has been added to Account with id 1a8d45ae-1216-6199-97bf-5f92d46f0a50"
    },
    "data": []
}

Tip if you haven’t already, upload the swagger found here
Api/docs/swagger/swagger.json
to a site like https://editor.swagger.io/
Which gives you some easier to use API docs

Any questions let me know :+1:

Sorted, thanks for all your help.

Cheers
Steve