Not able to update text tab value using updateTabs API

Here is the scenario i am working with. I am trying to update the text tabs value in the envelope. Here is the sample cofeescript code.

envelopesApi.listTabs(@accountId, envelopeId, recipientId).then((tabs) =>          
    updatedTabs =
      textTabs: []
      
    for tab in tabs.textTabs
      if data[tab.tabLabel]
        updatedTabs.textTabs.push { tabId: tab.tabId, value: data[tab.tabLabel] }
    
    envelopesApi.updateTabs(@accountId, envelopeId, recipientId, { templateTabs: docusign.TemplateTabs.constructFromObject(updatedTabs) }).then((tabs) =>
      console.log 'tabs: ' + JSON.stringify(tabs)
      cb null
    )
).catch((err) ->
  console.log err
)

The above call at updateTabs is throwing me the following error.

{
    status: 400,
    text: '{"errorCode":"INVALID_REQUEST_BODY","message":"The request body is missing or improperly formatted. No tabs specified."}',
    method: 'PUT',
    path: '/restapi/v2.1/accounts/2fc0822d-782d-43d6-b217-79d23aaed3a3/envelopes/35fc12b2-621f-412d-99c5-d8f3ab01c5ee/recipients/2/tabs'
},

Am i missing something here? Appreciate the help. Thanks.

Upvotes: 0

Views: 91

Answers (1)

Inbar Gazit
Inbar Gazit

Reputation: 14015

Fixed code:

envelopesApi.listTabs(@accountId, envelopeId, recipientId).then((tabs) =>          
    updatedTabs =
      textTabs: []
      
    for tab in tabs.textTabs
      if data[tab.tabLabel]
        updatedTabs.textTabs.push { tabId: tab.tabId, value: data[tab.tabLabel] }
    
    envelopesApi.updateTabs(@accountId, envelopeId, recipientId, { tabs: docusign.TemplateTabs.constructFromObject(updatedTabs) }).then((tabs) =>
      console.log 'tabs: ' + JSON.stringify(tabs)
      cb null
    )
).catch((err) ->
  console.log err
)

Upvotes: 1

Related Questions