2016-08-31 7 views
0

私はWebhookリスナーと入力データを操作するためのスクリプトを使用する内部アプリを持っています。私はそれにこれを掲示しています:以下のようにスクリプトステップでWebhook入力を使用できませんか?

curl -X POST -d '{ 
    "assignment_id": 12345, 
    "updated_custom_fields": [{ 
     "name": "RNVIDAYEBB", 
     "value": "updated!" 
     }, 
     { 
     "name": "QUFTXSIBYA", 
     "value": "and me too" 
     } 
    ], 
    "custom_fields": [{ 
     "id": 981, 
     "name": "RDEXDPVKRD", 
     "fields": [ 
      { 
      "id": 4096, 
      "name": "RNVIDAYEBB", 
      "default": "EDJEAJICYW", 
      "required": true, 
      "value": "Blah" 
      }, 
      { 
      "id": 4097, 
      "name": "QUFTXSIBYA", 
      "default": "", 
      "required": true, 
      "value": "" 
      }] 
    }] 
}' "https://hooks.zapier.com/hooks/catch/......" 

私のスクリプトは次のとおりです。

update_custom_fields_by_name_pre_write: function(bundle) { 
    var updatedFields = _.map(bundle.request.data.custom_fields, function(group) { 
     return _.map(group.fields, function(field) { 
      return _.extend(field, _.findWhere(bundle.request.data.updated_custom_fields, { name: field.name})); 
     }); 
    }); 
    bundle.request.data = updatedFields; 
    return bundle.request; 
} 

私はマージ・ロジックが良好であることを知っているが、それはcustom_fieldsupdated_custom_fields配列が中に存在していないように見えますbundle.request.dataオブジェクト。誰でもスクリプトにアクセスする方法を知っていますか?

答えて

0

_pre_writeの代わりに)受信静的webhookデータをキャプチャするためにupdate_custom_fields_by_name_catch_hookを使用する必要があるようです。これを使用すると、bundle.cleaned_request.custom_fieldsbundle.cleaned_request.updated_custom_fieldsのデータをキャプチャできます。

関連する問題