API: Add appendices

Loading contract appendices

HTTP POST 

https://cloud.sellandsign.com/calinda/hub/selling/do?m=uploadPicture&option_id=[option_id]

[With appendix in HTTP Part (multipart/form-data)]

Example on SELL&SIGN CLOUD

To upload an attachment whose option id is 1866.

https://cloud.sellandsign.com/calinda/hub/selling/do?m=uploadPicture&option_id=1866
Content-Length 54164	 	
Content-Type multipart/form-data; 
boundary=---------------------------17051144681837078108139936823737

[the image file "Annexe.png"]

Return:

[
   {
      "id":63,
      "optionId":1866,
      "lastModificationDate":1575304327455,
      "imageToken":"MTU3NTMwNDMyNzQ1NV8xODY2XzEyMjIz",
      "lastModificationPlace":"SERVER",
      "name":"20190913_143820.jpg",
      "contentType":"image/jpeg"
   }
]

But how do I find the option_id?

A SELL&SIGN contract template can contain several options and appendices, which can have types and semantics. In order to add an appendix to your contract, you must first create an option dependent on the contract and the element definition.

Here are the steps to be carried out:

  1. Retrieve the ID of the option definition “hub.selling.contract.default.picture.option” with the getOptionDefinitionByName
  2. Then, retrieve the list of element definitions associated with this option using getElementDefinitionByName by passing the ID of the previous option definition
  3. Next, create the option using GetOrCreateOption by passing the ID of the first element definition from the previous list
  4. As seen above: call uploadPicture by passing the ID of the option just created

1) Find the OptionDefinitionId of the option definition that will host the Appendix

If you are working on a particular contract template, you need to know which optionDefinitionId to use. But most people start with a PDF ADHOC contract (generic PDF contract). If this is your case, our team has provided you with the ContractDefinitionId of the generic PDF contract of your license, and you can retrieve the optionDefinitionId from there:

If you want more information about the options, please refer to the pre-requisite documentation, by clicking on the red link below:

Defining option values and Smartfields

https://cloud.sellandsign.com/calinda/hub/selling/model/optiondefinition/read?action=getOptionDefinitionByName

JSON input in the Body:
{
    "option_definition_name": "hub.selling.contract.default.picture.option",
    "contract_definition_id": [ContractDefinitionId]
}

Result:

{
    "id": 281021,
    "name": "hub.selling.contract.default.picture.option",
    "type": "PICTURE",
    "description": "",
    "pageId": 18243,
    "optionDefGroupId": 0,
    "syncTimer": 1589462203181,
    "helpId": 1,
    "userIdentifier": "",
    "lastModificationPlace": "SERVER",
    "required": false,
    "page_id": 18243
}

In this example the ID of the definition option of interest is “281021”.

2) Find the ElementDefinitionId of the option element that will host the appendix

For reasons that are too long to explain, it is now necessary to find the ID of the element of the option that will host the Appendix.

https://cloud.sellandsign.com/calinda/hub/selling/model/elementdefinition/read?action=getElementDefinitionByName

JSON input in the Body:
{
    "option_definition_id": 281021,
    "element_definition_name": ""
}

Result:

{
    "id": 419401,
    "name": "",
    "type": "PICTURE",
    "description": "",
    "optionDefinitionId": 281021,
    "syncTimer": 1589462203184,
    "lastModificationPlace": "SERVER",
    "value": "",
    "range": "",
    "imageToken": "",
    "image_token": "",
    "sync_timer": 1589462203184,
    "option_definition_id": 281021
}

In this example the ID of the definition element we are interested in is “419401”.

3) Create the Option that will carry the appendix(es)

Phew! We have the identifier we need to create the option that will carry the appendix(s) (and that will have the famous option_id).

https://[host]/calinda/hub/selling/model/option/update?action=getOrCreateOption

json input:
{
  "contract_id" : [Contract Id],
  "element_definition_id": [the element id of the option, which is 419401],
  "value": [value to be assigned to the option]
}

Result:

{
    "id": 555555,
    "contractId": [ContractId],
    "elementDefinitionId": 419401,
    "syncTimer": 1589462203184,
    "value": "",
    "lastModificationPlace": "SERVER"
}

That’s it! So the option ID is “555555”. You just have to pass it as a parameter of the “uploadPicture” call at the top of the page to add an appendix!

In case of HTTP error

In case of HTTP error An HTTP 400 error may indicate the absence of a required parameter or an inappropriate value. The message attached to the error will allow you to find the cause of the error. In the case of an HTTP 500 error, you can contact support on our support portal.