Delete/Remove/Clear Hyperlink using API

GarrettSever
edited 05/07/24 in API & Developers

While there are a wealth of articles, discussions, and examples of adding and updating hyperlinks in cells using the Smartsheet API, I struggled to find any concrete guidance on how to remove a hyperlink or clear a cell that contains one via the API. I need the equivalent of going into the sheet, hitting "Delete" in the cell, and then saving, but this does not seem possible via the API.

I have tried:

  • Passing both empty strings and Null values to the cell's "value" and "displayValue" fields.
  • Passing a "hyperlink" property value of Null as well as a "blank" hyperlink
  • Passing a "hyperlink" object with an empty string and Null value for the "url"
  • Passing a "hyperlink" object with a 0 and Null value for a "sightId"
  • Various combinations of the above.

Some of these return "Success," but the hyperlink remains, and some throw various 11## errors stating the hyperlink url, sheetId, or reportId values must be specified.

I'm perplexed by the apparent lack of a method in the API to remove or delete a hyperlink. If my approaches are incorrect, I'm eager to learn what specific values I need to pass through the API for the hyperlinks to be removed. Could someone shed some light on this?

Answers

  • Hi @GarrettSever

    Historically this was possible by passing an empty string as the cell value: "value": ""

    However using this I see the same thing that you're experiencing (a "success" statement but with no changes to the cell). I don't believe this is expected, but I'm unsure what changes may have been made. I see that you have already posted a Product Idea regarding this, thank you! I'll pass that feedback along to the product team.

    Cheers,
    Genevieve

    Need more help? 👀 | Help and Learning Center

    こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions

  • Thank you Genevieve! It is appreciated.

  • Hi @GarrettSever,

    I encountered similar issues while using the smartsheet-python-sdk to remove hyperlinks. When isolating the issue and testing using Postman, I was able to remove the hyperlink with a PUT request to URL: https://api.smartsheet.com/2.0/sheets/{sheet_id}/rows

    Headers:

    {"Authorization": "Bearer: {api_token}"}

    Payload:

    [{

    "id": "{row_id}",

    "cells": [{

    "columnId": {column_id},

    "value": "{some_value}",

    "hyperlink": null

    }]

    }]

    I then successfully updated this in my code using python's requests library with the same structure instead of using the smartsheet-python-sdk. I'm not sure which language or SDK you may be using, but hopefully this helps some!

  • Hi @GarrettSever (and thanks for chiming in, @ari_denary!)

    I've tested again today and the following structure works in Postman:

    {
    "cells": [
    {
    "columnId": xxxxx,
    "value": "Anything",
    "hyperlink": null
    }]
    }

    Let us know if this now works for you!

    Cheers,
    Genevieve

    Need more help? 👀 | Help and Learning Center

    こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions

  • To do remove a hyperlink using the smartsheet python api. Do this:

    from smartsheet.models import ExplicitNull
    
    cell.hyperlink = ExplicitNull()