Charmed Quark Systems, Ltd. - Support Forums and Community
help with doing an http post with data - Printable Version

+- Charmed Quark Systems, Ltd. - Support Forums and Community (https://www.charmedquark.com/vb_forums)
+-- Forum: General Discussion (https://www.charmedquark.com/vb_forums/forumdisplay.php?fid=3)
+--- Forum: CQC Support (https://www.charmedquark.com/vb_forums/forumdisplay.php?fid=9)
+--- Thread: help with doing an http post with data (/showthread.php?tid=9710)



help with doing an http post with data - bbrendon - 03-03-2016

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?

Code:
curl -X POST -H "Content-Type: application/json" -d '{"value1":"a","value2":"b","value3":"c"}' https://maker.ifttt.com/trigger/cqc_notify/with/key/cf_8ZeO4rVrss2VmyFty4f


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

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

        URLStr := "https://maker.ifttt.com/trigger/cqc_notify/with/key/dfg43fg34";
        ContType := "application/json";

        m_XCoder.ConvertTo(Data, DataBuf, ContLen);

        Try
            URLobject.Set(URLStr, FQTypes.Full);

            //ContLen := 0;

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

            RetCode.Clear();
            RetCode.AppendCard4(ResCode, Radices.Dec);
        EndTry;

        Catch
            Return 0;
        EndCatch;

        Return 1;
    EndMethod;



help with doing an http post with data - Dean Roddey - 03-03-2016

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.


help with doing an http post with data - bbrendon - 03-03-2016

AhhHH!HH!!!!
It worked first try. Why didn't I ask sooner?

Thanks.
Code:
ResCode := m_HTTP.SendPOST2(URLobject, 5000, "CQC", "*/*", RepText,
              OutHdrLines,ContType, DataBuf, ContLen, True, InHdrLines);



help with doing an http post with data - jkmonroe - 03-04-2016

whatcha doin'?


help with doing an http post with data - bjkiller - 10-07-2016

Can i get please whole code of this macro - i getting error: class LinesList was not found.