Note that there are some explanatory texts on larger screens.

plurals
  1. POworking on api call and getting data back in json format
    primarykey
    data
    text
    <p>I have a question regarding sending a Web API call to sendgrid:</p> <p>The following documentation is used to retrieve advanced stats:</p> <p><a href="http://sendgrid.com/docs/API_Reference/Web_API/Statistics/statistics_advanced.html" rel="nofollow">http://sendgrid.com/docs/API_Reference/Web_API/Statistics/statistics_advanced.html</a></p> <p>In the "Call" section, the following has been mentioned:</p> <pre><code>POST https://api.sendgrid.com/api/stats.getAdvanced.json POST Data api_user=your_sendgrid_username&amp;api_key=your_sendgrid_password&amp;start_date=2013-01-01&amp;end_date=2013-01-02&amp;data_type=global </code></pre> <p>I understand that I need to use cfhttp for the Web API call and I should be mentioning <code>"https://api.sendgrid.com/api/stats.getAdvanced.json"</code> in the url parameter of the <code>cfhttp</code> tag.</p> <p>Where do I need to mention api_user and api_key portion? I understand that I will have to mention my sendgrid's account username and password here. </p> <p>For Explanation Purpose let's consider the following dummy values for:</p> <pre><code>api_user = stack api_key = 123456 </code></pre> <p>Please let me know. I am trying to send an API call an get the data back in JSON format.</p> <p>Thanks</p> <p><strong>ATTEMPT #1</strong></p> <p>I am using the following code:</p> <pre><code>&lt;cfhttp url="https://api.sendgrid.com/api/stats.getAdvanced.json" method="POST" result="returnStruct"&gt; &lt;cfhttpparam name="api_user" value="stack" type="formfield"&gt; &lt;cfhttpparam name="api_key" value="123456" type="formfield"&gt; &lt;!--- &lt;cfhttpparam name="days" value="5" type="formfield"&gt; ---&gt; &lt;cfhttpparam name="start_date" value="2013-12-06" type="formfield"&gt; &lt;!--- &lt;cfhttpparam name="end_date" value="2013-12-09" type="formfield"&gt; ---&gt; &lt;/cfhttp&gt; &lt;cfdump var="#returnStruct#"&gt; </code></pre> <p>I am getting the following error in the form of Structure. Am I doing something wrong above? Please check my code below.</p> <pre><code>Charset [empty string] ErrorDetail [empty string] Filecontent {"error": "error in data_type: data_type is required"} Header HTTP/1.1 400 Bad Request Content-Type: text/html Connection: close Date: Tue, 10 Dec 2013 06:21:19 GMT Server: nginx/1.4.2 Mimetype text/html Responseheader struct Connection close Content-Type text/html Date Tue, 10 Dec 2013 06:21:19 GMT Explanation Bad Request Http_Version HTTP/1.1 Server nginx/1.4.2 Status_Code 400 Statuscode 400 Bad Request Text YES </code></pre> <p>I am wondering, which <code>data_type</code> it is referring to, as the documentation doesn't talks about it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload