Skip to content
This repository has been archived by the owner on May 7, 2022. It is now read-only.

400 Bad Request: Item date error when syncing #11

Open
M4tsuri opened this issue May 5, 2022 · 3 comments
Open

400 Bad Request: Item date error when syncing #11

M4tsuri opened this issue May 5, 2022 · 3 comments

Comments

@M4tsuri
Copy link

M4tsuri commented May 5, 2022

RSS3 SDK version: "rss3": "^0.8.19"

The code below can cause a 400 Bad Request:

let user = const news = new RSS3({
    endpoint: 'https://prenode.rss3.dev',
    // this is an random account with some items already posted to the prenode
    privateKey: '081ad9420a223dee54414be198bc6a07d23fa2028b00be6386aa389f9f2071e7',
});
let item = await user.items.custom.post({
    "title": `test`
})
console.log(item.id)
await user.files.sync();

Prenode returns:

{
    "code": 4004,
    "message": "Items date error"
}

It seems that there is an error when backend is parsing the repacked item list.

Thank you.

@songkeys
Copy link
Member

songkeys commented May 5, 2022

Could you try adding date_created and date_updated fields in the post body? e.g.,

let item = await user.items.custom.post({
    "title": `test`,
    "date_created": new Date().toISOString(),
    "date_updated": new Date().toISOString(),
})

Also note that the current RSS3 SDK (till May 2022) is still using the RSS3 v0.3.1 API, which is about to be deprecated. The v0.4.0 API will be available soon. But the custom item feature is being taken down after some consideration. We'll release further announcement during this month and provide some suggestions on how to migrate for our developers.

/cc @DIYgod

@M4tsuri
Copy link
Author

M4tsuri commented May 5, 2022

Thanks for your solution, but this code still throws a Parameter error.

As for the API changing, I checked out the v0.4.0 protocol and found that the custom item is replaced by a more generic Item type. I wonder if I'm not misunderstanding.

BTW, current when syncing after posting, it seems that the SDK will pull the full content list and resign it. I think there can be heavy tradeoff when sync files for a user with many history posts.

@songkeys
Copy link
Member

songkeys commented May 6, 2022

@M4tsuri

this code still throws a Parameter error.

Sorry about this. I'm not quite sure about this API. I think you may take a look at this test file https://github.com/NaturalSelectionLabs/RSS3-SDK-for-JavaScript/blob/86b7d60e1536a84e07ced193bea405829c1cabd3/test/items/custom.ts for a reference if you really want to use it though we decided to deprecate it.

I checked out the v0.4.0 protocol and found that the custom item is replaced by a more generic Item type.

No. Starting from v0.4.0, there's no way to create a custom item on RSS3 Network. This is a big decision that RSS3 won't support posting content but only indexing and delivering content. If you want to post your custom items, you are very welcome to post them on our supported networks. We will give away more details on our website and community.

there can be heavy tradeoff when sync files for a user with many history posts.

True. In this version of design, the maximum size for a list file is 2MB; if exceeded, pagination will happen with an "identifier_next" field. We thought this size and sign mechanism would be tolerated for clients. But I have to admit that the custom item design has some flaws and imperfect implementation when looking back now. That's a part of reason that we take it down in the following versions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants