Salesforce Case Generator for mbed

Revision:
3:8ad19b204ddf
Parent:
2:670837d3e248
Child:
4:f506cc61e09e
--- a/SalesForceCaseGenerator.cpp	Wed Aug 27 16:52:58 2014 +0000
+++ b/SalesForceCaseGenerator.cpp	Wed Aug 27 18:09:46 2014 +0000
@@ -39,25 +39,33 @@
      memset(data,0,BUFFER_LENGTH+1);
      memset(result,0,BUFFER_LENGTH+1);
      
-     // create the case
-     sprintf(data,"{\"subject\":\"%s\",\"description\":\"%s\"}", subject, description);
-          
-     // Create the inbound and outbound buffers
-     HTTPText http_data(data,strlen(data)+1);
+     // set addl header information
+     char headers[] = "User-Agent: curl/7.33.0\nAccept: */*\n" ;
+        
+     // build the new SF case
+     sprintf(data,"{\"subject\":\"%s\",\"description\":\"%s\"}",subject,description);
+    
+     // covert to the HTTP data types
+     HTTPText new_case(data,strlen(data)+1);
      HTTPText http_result(result,BUFFER_LENGTH);
+        
+     //this->m_http.basicAuth("<username>", "<password>");
+     this->m_http.setHeader(headers) ;
+     this->m_http.setSSLversion(1) ; /* TLSv1.0 */
           
      // POST the case and check the response
-     this->m_logger->log("Sending Request...\r\nlength=%d bytes",strlen(data));
-     if (this->m_http.post(DF_CASE_GEN_URL,http_data,&http_result) == 0) {
+     this->m_logger->log("Sending Request...");
+     int ret = this->m_http.post(DF_CASE_GEN_URL,new_case,&http_result);
+     if (!ret) {
         this->m_logger->log("Parsing Reply...");
         success = this->contains(result,"status","ok");
         if (success) 
             this->m_logger->log("Case generated successfully");
         else 
-            this->m_logger->log("Case generation FAILED: %s",data);
+            this->m_logger->log("Case generation FAILED");
      }
      else {
-        this->m_logger->log("Failed to send get request");
+        this->m_logger->log("Failed to send request");
      }
      
      // return our status