Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Ricardo Dias
    @slowdata
    * TypeError: Cannot read property 'indexOf' of null
    at isOnPremUrl (L:\testes\sharepoint-node\node_modules\node-sp-auth\lib\src\auth\IAuthOptions.js:6:17)
    Sergei Sergeev
    @s-KaiNet

    @slowdata you have an error in your url -

    const uri = `"https://....

    " is not needed, just

    const uri = `https://...

    also why do you use extra {} in items({${id}})? You should use just tems(${id})
    and for file name just FileName='test.csv')

    Ricardo Dias
    @slowdata
    @s-KaiNet , true. Thkx.
    Still have an error. 400 - {"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"pt-PT","value":"A expressão \"lists/GetByTitle('BO_SSD_teste')/items({35})/AttachmentFiles/add(FileName='{test.csv}')\" não é válida."}}}
    Somthing is not valid
    Sergei Sergeev
    @s-KaiNet
    you haven't fixed items and file name issues, please try fixing them
    Ricardo Dias
    @slowdata
    So the url is invalid you say? ok. Don't now where the problem is...
    Sergei Sergeev
    @s-KaiNet
    items({${id}}) should be items(${id})
    FileName='{test.csv}' should be FileName='test.csv'
    Ricardo Dias
    @slowdata
    REally??
    so dumb..
    thkx Segei
    Ricardo Dias
    @slowdata
    Sergei can you help me with a file problem. I uploaded a csv file and it was ok. Tried with a ZIP file and when i wen't to download it it doesn't open. How can i read the file so it is in the original state.
    So when i download the file it opens nicelly
    Sergei Sergeev
    @s-KaiNet
    it depends how you read a file. Something below should work:
    var file = fs.readFileSync("path to the file")
    spr.post(url, {
     body: file,
    .....
    }
    Ricardo Dias
    @slowdata
    Thats how I made it. My zip is 10k when downloaded is 35k does not open
    const file = await fs.readFile(path.resolve(__dirname, fileName)
    const r = await spr.post(uri, {
    body: file,
    headers: {
    "X-RequestDigest": digest,
    "X-HTTP-Method": "POST",
    "IF-MATCH": "*",
    },
    });
    Sergei Sergeev
    @s-KaiNet
    strange... if you try any other binary file, say image, does it work?
    Ricardo Dias
    @slowdata
    1m.. testing it
    used png file. From 31k whent 105k and it opens with nothins
    Windows 10 image vier says: It looks like we don't support this file format
    Sergei Sergeev
    @s-KaiNet
    you use await fs.readFile - are you sure, that fs.readFile returns a promise?
    Ricardo Dias
    @slowdata
    const fs = require("fs").promises;
    should it be a stream and not a buffer?
    Sergei Sergeev
    @s-KaiNet
    ah... ok
    basically buffer should work
    Ricardo Dias
    @slowdata
    I doesn't
    it
    am I missing some header?
    Sergei Sergeev
    @s-KaiNet
    but just to be sure, try saving the file into the local file system and check if you can open it
    Ricardo Dias
    @slowdata
    I rhight clicked the link. Saved the file and it doesn't work
      const file = await fs.readFile(path.resolve(__dirname, fileName), {
        encoding: null,
      });
    Sergei Sergeev
    @s-KaiNet
    I mean try read the file with fs.readFile and then save it with fs to local file system, in your node app
    Ricardo Dias
    @slowdata
    ok
    It works fine
    from vpn.png and made coisas.png and it opens perfectly
    so it's the api call or sharepoint!?!?!
    Sergei Sergeev
    @s-KaiNet
    yep, it looks like smth is wrong with api call
    try to add json: false to the list of request parameter, i.e.
    const r = await spr.post(uri, {
        body: f,
        json: false,
        headers: {
          "X-RequestDigest": digest,
          "X-HTTP-Method": "POST",
          "IF-MATCH": "*",
          "Content-Length": f.length,
        },
      });
    Ricardo Dias
    @slowdata
    Corret!!!!!!
    Bingo
    Thkkx once again.
    Sergei Sergeev
    @s-KaiNet
    cool! :)
    Ricardo Dias
    @slowdata
    I will need to buy you a beer!! :)
    To you and Andrew
    Sergei Sergeev
    @s-KaiNet
    no problem :)
    I will write to you, when I next time be in Portugal :)
    Ricardo Dias
    @slowdata
    Please do it!!
    If we survive this shit!!
    Sergei Sergeev
    @s-KaiNet
    oh yehh..