Search code examples
attask

Attask - Pass backslash (\) in URL as value


I am trying to pass set of values which has backslash("\") in them. This breaks the URL. The URL I submit is https://{mycompany}.attasksandbox.com/attask/api/project?ID=57ba84---1&updates={"description":"ToImplementWorkFront","URL":"T:%5CTechnologyWorkRequests%5C2016%5CTAD160888_Communications"}&apiKey=g--t&method=put

I basically want to pass values to URL field as "URL": "T:\TechnologyWorkRequests\2016\TAD160888_Communications"

I understand backslash is an unsafe character and hence encoded as %5C as well as %255C- but I get JSON parsing error. I am able to pass a forward slash(/) encoding it as %2F but I am not able to pass "\" character. Can any one please help? Thanks in advance!


Solution

  • For this kind of task you should use POST instead of GET method. If you still want to use GET you can do something like following example:

    "https://posturl/?update=" + encodeURIComponent("{ \"path\": \"C:\\Windows\\System32\"}")
    

    More safe:

    var data = {
        "path": "C:\\Windows\\System32\"
    }
    var url = "https://posturl/?update=" + encodeURIComponent(JSON.stringify(data))