Jump to content
  • IronPython script to call a web service or retrieve URL in Spotfire®


    Introduction

    Spotfire® allows users to create custom functionalities using scripts in IronPython. Using the below script, users can configure a button that when clicked will call a web service or retrieve a URL. A sample URL that returns JSON values is shown below.

    Call Web Service or Retrieve URL

    The below script  will call a web service or retrieve a URL

    # Copyright © 2017. TIBCO Software Inc.  Licensed under TIBCO BSD-style license.
    
    # Import the necessary packages
    import clr
    clr.AddReference('System.Web.Extensions')
    from System.Web.Script.Serialization import JavaScriptSerializer
    from System.Net import WebClient
    
    # Create a web client
    client = WebClient()
    
    # Specify a resource of type string to download
    strURL = "http://mywebserveraddress/location/query?format=json""
    
    # Download the results of that URL
    results = client.DownloadString(strURL)
    
    # print these results
    print results
     

    See Also:

    Here is a working example of a fully implemented Web Service integration using IronPython.

    https://community.spotfire.com/s/article/IronPython-Script-to-access-data-from-Web-Service-using-HttpWebRequest-and-parse-returned-JSON-with-JavaScriptSerializer

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...