Bungie-net / api

Resources for the Bungie.net API
Other
1.22k stars 92 forks source link

EquipItem endpoint returning 500 error #1212

Open egraves2 opened 4 years ago

egraves2 commented 4 years ago

I wrote a POST method for the EquipItem endpoint, but I keep getting a 500 error.

The body of my POST includes the correct itemId, characterId, and membershipType. My header includes the Authorization token. The url seems totally correct. So I'm having trouble figuring out why I'm getting this Internal Server Error. Any help would be super appreciated.

Here's my code:

const fetch = require('node-fetch')
let root = 'https://www.bungie.net/Platform'
    var equipEP = `/Destiny2/Actions/Items/EquipItem/`
    const url = root + equipEP
module.exports = async function(req,res){ 
    try {
    const {itemId} = req.query.itemId
    const {characterId} = req.query.characterId
    const {membershipType} = req.query.membershipType
    const {token} = req.query.token
  const r = await fetch(url, {
    method:'POST',
    headers:{ 
      'Authorization':`Bearer ${token}`, 
      'Content-Type':'application/x-www-form-urlencoded',
    },
    body: `itemId=${itemId}&characterId=${characterId}&membershipType=${membershipType}`
    })
  const result= await r.json()
res.status(200).send(result)
  } catch(e) {
      res.status(500).send(e.message)
  }
justrealmilk commented 4 years ago

itemHash or itemInstanceId?