SaveDataSetAs not working on Inrupt dot com - but works on Inrupt dot net

SaveDataSetAs not working on Inrupt dot com - but works on Inrupt dot net

I’ve been running the tutorials (Getting Started: Part 2 — Inrupt JavaScript Client Libraries) - all is good until I get to overwriting an existing data set

It works in Inrupt dot net, but running it on Inrupt dot com I get the following error:
*ErrorError: Storing the Resource at [https://pod.inrupt.com/xxxx/testdata/myReadingList] failed: [412] [Precondition Failed]. The SolidDataset that was sent to the Pod is listed below. …. *

If I write to a new reading list - then it all works - so it can’t be the directory structure that I don’t have permissions to write to.
Not sure what the real difference is in what I’m doing - so any help would be appreciated!

2 Likes

Apologies for cutting stuff out - but says I can only use 2 url links as a new user!

2 Likes

Hi @stoods, welcome to the Solid forum! Do you happen to have your source code anywhere that we can look at? Is the SolidDataset you’re saving based on the one that’s located at the given URL (i.e. did you add data to a SolidDataset obtained using getSolidDatasetAt("https://pod.inrupt.com/xxxx/testdata/myReadingList") or did you create it using createSolidDataset())? What data are you writing?

1 Like

Hey all – if using the tutorial as is, then it’ll always do a createSolidDataset() - so that saveSolidDataset will try a create instead of an update (if the SolidDataset passed into saveSolidDataset does not have an identifying URL associated with it, the save function will do a create instead of an update). Sorry about that, @stoods. I was trying to keep the getting started sections as simple as possible to go through the create → modify locally → save flow, but I will admit, even though I made the decision on the just blanket createSolidDataset() every time, I did go back and forth between that and trying to retrieve the SolidDataset first and if it 404s, then, do the createSolidDataset() (since high likelihood that people would rerun the app). At the time of the decision, I figured we’ll see how the blanket createSolidDataset() goes and modify as we get feedback. So, very much appreciate your feedback!

   //You can import FetchError  from "@inrupt/solid-client"

    try {
        myReadingList = await getSolidDataset(readingListUrl, { fetch: fetch });
    } catch (error) {
        if (error instanceof FetchError) {
            if (error.statusCode === 404) {
                myReadingList = createSolidDataset();
            }
            else {
                console.error(error.message);
            }
        } else {
            console.error(error.message);
        }
    }
2 Likes

It’s strange how the 2 pods treat them differently!
I think it would be useful to add this in - as it shows the re-usability aspect, with a lot nicer errors when you try to re-run it!

I did however have to define the reading list as a var to make the above work - i.e.
var myReadingList;

@kay-kim - I’m currently working on a version that you could deploy to Heroku - I’ve had to alter it a moderate amount though to make it work - if you want a cut of the code to look at - let me know and I’ll give you a link to the Github repo for you to check out with what I’ve had to change

2 Likes

Oh, most definitely. Unfortunately, I’m not too familiar with the behavior on inrupt.net, so like a weenie, I skipped that part of your question :smiley:

Agree. Will schedule some time in the next couple of weeks to incorporate that.

Ah, yes. I had changed the const to let in mine, but failed to copy that during my copy+paste. D’oh.

Oh, that would be lovely. Much appreciated!

2 Likes

@kay-kim - Sorry for the timelapsed response!

Version is now on Github which you can check out:

The local packages which require installing are a bit different, as are the run instructions - but primarily the same - I’ve added them into the readme - but readme’s are never my strong point!

# Instructions for creating POD POC in Heroku

NPM Packages that require installing:
npm i -D webpack webpack-cli webpack-dev-server
npm i html-webpack-plugin html-loader --save-dev
npm install @inrupt/solid-client @inrupt/solid-client-authn-browser @inrupt/vocab-common-rdf
npm install buffer
npm install express

# Instructions for running
To run locally:
npm run dev
http://127.0.0.1:8080/
1 Like

Thank you!!!

Absolutely no worries!!! Appreciate your willingness to share.

Also, the updated Getting Started pt 2 is out. It’s tweaked a bit from the above:

  • Now, after we fetch an existing reading list – we delete all the Things from it so that the new list completely overwrites the old list (as opposed to appending). We could also have instead tried to deleteSolidDataset first and then just createSolidDataset (I mention this as an alternative in the explanation of the code)
  • Now, instead of instanceof, we use duck typing (where we just check for the error.status property) as the use of instanceof can have issues (much thanks to Vinnie for the review – he knows all the things :smiley: and is generous enough to share)