2017-03-21 27 views
0

我想要一個HTTP POST發送到https://maker.ifttt.com/trigger/event_name/with/key/xxxxxxxxxxxxxxxxxxxxxxxxxxx使用IFTTT商網絡掛接採用了棱角分明2.POST到IFTTT採用了棱角分明2

正在接收請求,但身體不行。

post(): Promise<string> { 
let headers = new Headers({ 'Content-Type': 'application/json'}); 
let options = new RequestOptions({ headers: headers }); 
console.log(options) 
let body = { "value1": "21223232"}; 
console.log(body) 
return this.http.post(this.webhookUrl, body, options) 
     .toPromise() 
     .then(this.extractData) 
     .catch(this.handleError); 

應該有value1: 21223232並與{{值1}}見諸報端,但我沒有得到運氣。

另外值得注意:

curl -X POST -H "Content-Type: application/json" -d '{"value1":"21223232"}' https://maker.ifttt.com/trigger/event_name/with/key/xxxxxxxxxxxxxxxxxxxxxxxxxxx 

工作

有沒有人經歷過這個?

回答

0

我終於解決了這個使用

let headers = new Headers({ 'Content-Type': 'application/json' }); 
let body = new FormData(); 
body.append('value1', "21223232"); 
return this.http.post(this.webhookUrl,body,headers) 
     .toPromise() 
     .then(this.extractData) 
     .catch(this.handleError); 

這是通過使用離子2 FORMDATA()

0

我認爲這將是作爲可觀察到的清潔劑,和或@ .ajax的請求。

data = new FormData().append(); 

$.ajax(
       { 
        'url' : targetUrl, 
        'crossDomain': true, 
        'type': 'POST', 
        'data': data 
       } 
      ).done(function (rsp) { 
       //..code 
      }).fail(function (rsp) { 
       Error(); 
      });