Charmed Quark Systems, Ltd. - Support Forums and Community

Full Version: help with doing an http post with data
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Looking for a clue here ... I'm trying duplicate the curl command below with CML. It kinda works, but the Data isn't getting passed. I have a feeling I'm using the SendPost method incorrectly. Any thoughts?

curl -X POST -H "Content-Type: application/json" -d '{"value1":"a","value2":"b","value3":"c"}'

    Method runMe([Out] String RetCode) Returns Int4    Begin
            LinesList   OutHdrLines;
            LinesList   InHdrLines;
            LinesList   PostVals;
            URL         URLobject;
            String      RepText;
            String      ContType;
            MemBuf      DataBuf;
            Card4       ContLen;
            Card4       ResCode;
            String      URLStr;
            String      Data;

        Data := "{\"value1\":\"a\",\"value2\":\"b\",\"value3\":\"c\"}";

        URLStr := "";
        ContType := "application/json";

        m_XCoder.ConvertTo(Data, DataBuf, ContLen);

            URLobject.Set(URLStr, FQTypes.Full);

            //ContLen := 0;

            ResCode := m_HTTP.SendPOST(URLobject, 5000, "myAgent", "*/*", PostVals
                , RepText, OutHdrLines, ContType, DataBuf, ContLen
                 , InHdrLines);

            RetCode.AppendCard4(ResCode, Radices.Dec);

            Return 0;

        Return 1;
There's another POST variant that will make it easier and make sure it gets done right. It takes the post values as a set of key/value pairs. Try using that one.
It worked first try. Why didn't I ask sooner?

ResCode := m_HTTP.SendPOST2(URLobject, 5000, "CQC", "*/*", RepText,
              OutHdrLines,ContType, DataBuf, ContLen, True, InHdrLines);
whatcha doin'?
Can i get please whole code of this macro - i getting error: class LinesList was not found.