2017-04-11 21 views
0

を取得して動作していない呼び出すPUT私はカール、SOAPUIや闊歩を使用してサービスを呼び出すときにそれが動作する、だから、(も試みノードフェッチ)axiosを使用して、私の急行アプリから別のサービスを呼び出すためにaxiosは415

をしようとしています。しかし

curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' -d '"02"' 'http://example.com/api/v1/something' 

私は私が手

axios.put('http://example.com/api/v1/something', '"03"')  
     .then((response) => { 
      res.sendStatus(200); 
     }) 
     .catch((error) => { 
      console.log(error); 
      res.sendStatus(500); 
    }); 

を使用してみてください "リクエストは、ステータスコードで失敗しました415" ヘッダにContent-Typeのを追加することにより、固定

+0

それは私が "03"がhttp://jsonlint.com/の有効なJSONであるかどうかをチェックしたものです。 – shresthaal

答えて

0

  axios({ 
       method: 'PUT', 
       url, 
       data: JSON.stringify(req.body), 
       headers:{'Content-Type': 'application/json; charset=utf-8'} 
      })  
      .then((response) => {    
       res.sendStatus(200); 
      }) 
      .catch((error) => { 
       logger.error(error); 
       res.status(500).send(error); 
      });