Post Notification with request module

Hello, I’m trying to create a notification and send that notification to another user whithout using the solid hook. My problem is that the id of the notification seems to be created automatically, and so, it’s different from the one I’m passing as parameter in the createNotificationContent method (showed below).

This is what I’m currently getting:

or, if you’d like to see the source section:

My code for creating the notification and its content is the following:

export async function postNotification(webIdFriend, content, uuid) {
    var inbox = webIdFriend + "/viade/inbox/";

    await request({
        method: "POST",
        uri: inbox,
        body: content,
        headers: {
            "Content-Type": "text/turtle"
        }
    },
        function (error, response, content) {
            if (error) { 
                return false; 
            } else {
                return true;
            }
        })
}

export function createNotificationContent(type, title, webId, routePath, time, uuid) {
    return `@prefix terms: <http://purl.org/dc/terms#>.
          @prefix as: <https://www.w3.org/ns/activitystreams#> .
          @prefix schema: <http://schema.org/> .
          @prefix solid: <http://www.w3.org/ns/solid/terms#> .
          @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
          @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
          @prefix : <${webId + `viade/inbox/` + uuid + `.ttl`}>.
          <${webId + `viade/inbox/` + uuid + `.ttl`}> a as:${type} ;
          schema:license <https://creativecommons.org/licenses/by-sa/4.0/>;
          terms:title "${title}" ;
          as:summary "${routePath}" ;
          as:actor <${webId}> ;
          solid:read "false"^^xsd:boolean ;
          as:published "${ time}"^^xsd:dateTime .`
}

I’m using the module request in order to do the post request.

How could I create that id myself?

Thanks in advance

1 Like

You can suggest a name for a file by adding a slug to the POST. However Solid can change that name when it stores the file. In order to know the name it stores the file under, you need to read the location header of the response from the POST. In some circumstances you create resources with PUT, those always have the exact name you gave it.

1 Like

Here’s an example of using a slug:

solid.auth.fetch(  PARENT_CONTAINER_URI, {
  method:"POST",
  headers:{
    slug: FILENAME
    link: '<http://www.w3.org/ns/ldp#Resource>; rel="type"',
    "content-type": FILETYPE
  },
  body: FILECONTENT
})

I used the slug approach and it works fine:

Thank you so much!!