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

**URL:** <https://forum.solidproject.org/t/savedatasetas-not-working-on-inrupt-dot-com-but-works-on-inrupt-dot-net/4509>\
**Category:** Build a Solid App\
**Created:** [July 22, 2021, 2:50pm UTC](https://forum.solidproject.org/t/savedatasetas-not-working-on-inrupt-dot-com-but-works-on-inrupt-dot-net/4509 "2021-07-22T14:50:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![stoods](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/stoods/32/2858_2.png) [@stoods](https://forum.solidproject.org/u/stoods)\
**Post date:** [July 22, 2021, 2:50pm UTC](https://forum.solidproject.org/t/savedatasetas-not-working-on-inrupt-dot-com-but-works-on-inrupt-dot-net/4509/1 "2021-07-22T14:50:02Z")

</div>

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](https://docs.inrupt.com/developer-tools/javascript/client-libraries/tutorial/getting-started-part2/)) - 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](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!

---

<div class="post-metadata">

**Author:** ![stoods](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/stoods/32/2858_2.png) [@stoods](https://forum.solidproject.org/u/stoods)\
**Post date:** [July 22, 2021, 2:50pm UTC](https://forum.solidproject.org/t/savedatasetas-not-working-on-inrupt-dot-com-but-works-on-inrupt-dot-net/4509/2 "2021-07-22T14:50:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Vincent](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@Vincent](https://forum.solidproject.org/u/Vincent)\
**Post date:** [July 23, 2021, 4:30pm UTC](https://forum.solidproject.org/t/savedatasetas-not-working-on-inrupt-dot-com-but-works-on-inrupt-dot-net/4509/3 "2021-07-23T16:30:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kay-kim](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/kay-kim/32/2860_2.png) [@kay-kim](https://forum.solidproject.org/u/kay-kim)\
**Post date:** [July 25, 2021, 1:05am UTC](https://forum.solidproject.org/t/savedatasetas-not-working-on-inrupt-dot-com-but-works-on-inrupt-dot-net/4509/4 "2021-07-25T01:05:22Z")

</div>

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!

```auto
   //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);
        }
    }

```

---

<div class="post-metadata">

**Author:** ![stoods](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/stoods/32/2858_2.png) [@stoods](https://forum.solidproject.org/u/stoods)\
**Post date:** [July 26, 2021, 1:34pm UTC](https://forum.solidproject.org/t/savedatasetas-not-working-on-inrupt-dot-com-but-works-on-inrupt-dot-net/4509/5 "2021-07-26T13:34:01Z")

</div>

> [@kay-kim](#):
>
> ```auto
> 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);
> }
> }
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![kay-kim](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/kay-kim/32/2860_2.png) [@kay-kim](https://forum.solidproject.org/u/kay-kim)\
**Post date:** [July 26, 2021, 6:08pm UTC](https://forum.solidproject.org/t/savedatasetas-not-working-on-inrupt-dot-com-but-works-on-inrupt-dot-net/4509/6 "2021-07-26T18:08:06Z")

</div>

> [@stoods](#):
>
> It’s strange how the 2 pods treat them differently!

Oh, most definitely. Unfortunately, I’m not too familiar with the behavior on [inrupt.net](http://inrupt.net), so like a weenie, I skipped that part of your question 😃

> [@stoods](#):
>
> 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!

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

> [@stoods](#):
>
> I did however have to define the reading list as a var to make the above work - i.e.  
> var myReadingList;

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

> [@stoods](#):
>
> @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

Oh, that would be lovely. Much appreciated!

---

<div class="post-metadata">

**Author:** ![stoods](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/stoods/32/2858_2.png) [@stoods](https://forum.solidproject.org/u/stoods)\
**Post date:** [August 2, 2021, 9:15am UTC](https://forum.solidproject.org/t/savedatasetas-not-working-on-inrupt-dot-com-but-works-on-inrupt-dot-net/4509/7 "2021-08-02T09:15:52Z")

</div>

@kay-kim - Sorry for the timelapsed response!

Version is now on Github which you can check out:

> **[GitHub - Stoods-hd/pods-part2-heroku: Heroku deployable version of Pods...](https://github.com/Stoods-hd/pods-part2-heroku)**
>
> Heroku deployable version of Pods Getting Started: Part 2 - GitHub - Stoods-hd/pods-part2-heroku: Heroku deployable version of Pods Getting Started: Part 2

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!

```auto
# 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/

```

---

<div class="post-metadata">

**Author:** ![kay-kim](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/kay-kim/32/2860_2.png) [@kay-kim](https://forum.solidproject.org/u/kay-kim)\
**Post date:** [August 2, 2021, 2:24pm UTC](https://forum.solidproject.org/t/savedatasetas-not-working-on-inrupt-dot-com-but-works-on-inrupt-dot-net/4509/8 "2021-08-02T14:24:22Z")

</div>

Thank you!!!

> [@stoods](#):
>
> @kay-kim - Sorry for the timelapsed response!

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

Also, the updated [Getting Started pt 2](https://docs.inrupt.com/developer-tools/javascript/client-libraries/tutorial/getting-started-part2/) 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 😃 and is generous enough to share)
