# How do I do the following curl command in AS3?

**URL:** <https://forum.kirupa.com/t/how-do-i-do-the-following-curl-command-in-as3/331713>\
**Category:** Uncategorized\
**Created:** [October 3, 2013, 12:06am UTC](https://forum.kirupa.com/t/how-do-i-do-the-following-curl-command-in-as3/331713 "2013-10-03T00:06:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tedri\_Mark](https://avatars.discourse-cdn.com/v4/letter/t/51bf81/32.png) [@Tedri\_Mark](https://forum.kirupa.com/u/Tedri_Mark)\
**Post date:** [October 3, 2013, 12:06am UTC](https://forum.kirupa.com/t/how-do-i-do-the-following-curl-command-in-as3/331713/1 "2013-10-03T00:06:07Z")

</div>

Hi,

I’m playing about with the habitRPG api, and trying to make an app in flash which uses it.

The following:

curl -X POST --compressed -H “Content-Type:application/json”   
-H ‘x-api-user: xxxxxxxxxxxxxxxxxx’   
-H ‘x-api-key: xxxxxxxxxxxxxxxxxxx’   
-d ‘{“text”:“from the api!”,“type”:“todo”}’   
[https://habitrpg.com/api/v1/user/task](https://habitrpg.com/api/v1/user/task)

adds a task to my todo list, so far I’ve got this:

```auto
public function newTask():void 
        {
            
             var todo:Array = new Array ();
             todo.push ( { "text":"from the as3 api!", "type":"todo" } );
             var JsonObj:String = JSON.stringify(todo);
            trace(JsonObj);
             
            //From here
            
            var RequestURL = "https://habitrpg.com/api/v1/user/task";

        var JSONLoader:URLLoader = new URLLoader();
        JSONLoader.dataFormat=URLLoaderDataFormat.TEXT;

        JSONLoader.addEventListener(IOErrorEvent.IO_ERROR, GetBookmarkURLError, false, 0, true);
        JSONLoader.addEventListener(Event.COMPLETE, postSuccess, false, 0, true);

        var hdr:URLRequestHeader = new URLRequestHeader("Content-type", "application/json");
        var hdr2:URLRequestHeader = new URLRequestHeader("x-api-user", "xxxxxxxxxxxxxxxx");
        var hdr3:URLRequestHeader = new URLRequestHeader("x-api-key", "xxxxxxxxxxxxxxxxx")
        var request:URLRequest = new URLRequest(RequestURL);
        request.requestHeaders = [new URLRequestHeader("Content-Type", "application/json"),new URLRequestHeader("x-api-user", "67a21444-29bb-406d-ae55-ec8b8cc42736"),new URLRequestHeader("x-api-key", "858f3d44-5573-4175-bd41-1abf746d977c")];
        request.data = JsonObj;
        request.method = URLRequestMethod.POST;
        
         try 
        {
            JSONLoader.load(request);
        }
        catch (error:ArgumentError) 
        { 
            trace("An ArgumentError has occurred."+error.errorID.toString()); 
        } 
        catch (error:SecurityError) 
        { 
            trace("A SecurityError has occurred."); 
        }
        catch (error:Error) 
        {
            trace("Unable to load requested document.");
        }
     
        }

private function postSuccess(e:Event):void 
        {
            trace ("SuccessfulPOST!");
            var myResults = JSON.stringify(e.target.data);
                        trace ("JSON result is " + myResults);
        }

```

which traces:  
SuccessfulPOST!  
JSON result is “[{“text”:“from the as3 api!”,“type”:“todo”}]”

It seems these backslashes are being inserted and this is why nothing is being posted, how do I fix this?

Thanks,

Mark
