Search code examples
phpjavascriptpythonrubygoogle-fusion-tables

Fusion Tables API: How do I make a PUT request to update a style via Ruby, JavaScript, or other languages?


I was looking at this Fusion Tables API page on how to update a Fusion Table's style settings via the Fusion Tables API.

Apparently, you must make a PUT request in order to update the Fusion Table's style.

I was wondering: How do I do that in Ruby or JavaScript? And is it possible to do it in other popular languages (e.g., pHp, Python)?


Solution

  • In Python you can easily perform a PUT HTTP request using the Requests module.

    import requests
    
    key = u'your_api_key'
    url = u'https://www.googleapis.com/fusiontables/v1/tables/tableId/styles/styleId?key=%s' % key
    
    body = dict()
    body[u'markerOptions.iconName'] = u'geographic_features'
    # put other settings here
    
    r = request.put(url, data=body)
    

    Requests documentation can be found here : http://docs.python-requests.org/en/latest/