Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
Axios created string returns 403 forbidden since the URL is broken but works fine hardcoded string

Axios created string returns 403 forbidden since the URL is broken when the URL is made by combining several strings.

Here is an example: This works fine:

const inventory = await axios.get("http://steamcommunity.com/inventory/76561198164672016/730/2?l=english&count=5000");

It returns the correct results.

But when using the same URL, just combining different values, it does not work.

const testId = 76561198164672016;
const path = "http://steamcommunity.com/inventory/"+testId.toString()+"/730/2?l=english&count=5000"
    const inventoryWithPath = await axios.get(path);

This returns an error. I don't understand how this can happen when the strings are the same... Here is the full code.

const axios = require('axios').default;
const testId = 76561198164672016;


async function getInventory(){
    try{

    //invetory works fine and returns correct values
    const inventory = await axios.get("http://steamcommunity.com/inventory/76561198164672016/730/2?l=english&count=5000");

    //Even though this has the same URL it returns an error. Why and how can I request based on the path?
    const path = "http://steamcommunity.com/inventory/"+testId.toString()+"/730/2?l=english&count=5000"
    const inventoryWithPath = await axios.get(path);
    
    //console.log(inventoryWithPath)
    console.log(inventory)
    return inventory;
    }
    catch(err){
        console.log(err);
        console.log("Error happened")
    }
}
module.exports={getInventory}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As suggested in the comments, the reason your code isn't working is because testId > Number.MAX_SAFE_INTEGER. What you can do to solve this is use BigInt like this:

const path = "http://steamcommunity.com/inventory/" + BigInt(testId).toString() + "/730/2?l=english&count=5000"

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!