Troubles with roUrlTransfer.PutFromString()

I'm trying to perform a PUT request to a device with a REST API. I'm able to do it successfully with curl via command line, but not BrightSign Player. When I run the following code, I get CURLE_SEND_FAIL_REWIND (-65), and am unsure of how to proceed.

powerURL = "http://x.x.x.x/restapi/relay/outlets/"
outlets = "=0,1"
actionURI = "/state/"
putData = "value=true"
requestURL = powerURL + outlets + actionURI
response = ""

print "Web Switch URL: " + requestURL

request = CreateObject("roUrlTransfer")
request.SetUrl (requestURL)
request.AddHeader("X-CSRF", "x")
request.AddHeader("Content-Type", "application/x-www-form-urlencoded")
request.AddHeader("Accept", "application/json")
request.SetUserAndPassword("xxx", "xxx")
result = request.PutFromString(putData)
print result


  • 0
    Jason Northrup

    If I use request.SyncMethod() instead of request.PutFromString(), result is "unsupported"

    result = request.SyncMethod({ method: "PUT", request_body_string: putData, response_body_string: response })


    This is the curl request I'm trying to replicate, which works fine:

    curl -u xxx:xxx -X PUT -H "X-CSRF: x" -H "Accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" --data "value=false" "http://x.x.x.x/restapi/relay/outlets/=0,1/state/"

  • 0
    Bright Scripters

    Without going deep into this question, I'm noticing that in the code there is

    putData = "value=true"

    while in the CLI you have

    --data "value=false"

  • 0
    Jason Northrup

    Ultimately, I will be sending both "value-true" and "value=false" at different times, to turn outlets on and off.

  • 0
    Bright Scripters

    The CURLE_SEND_FAIL_REWIND might suggest that it is an authentication related issue.

    Is basic authentication your only option?

    Can you try with HTTP digest authentication?


    Also, you could try Enable system log debugging, and look for more information in the system log, that might help with troubleshooting.



    Wireshark maybe?

Please sign in to leave a comment.