Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating items to be read does not seem to work #3

Closed
cowens opened this issue Jul 1, 2013 · 9 comments
Closed

Updating items to be read does not seem to work #3

cowens opened this issue Jul 1, 2013 · 9 comments
Labels

Comments

@cowens
Copy link

cowens commented Jul 1, 2013

I am hitting:

https://theoldreader.com/reader/api/0/edit-tag?i=51d133b76f48eae654007b69&a=user/-/state/com.google/read

and getting back a response of

OK

but item 51d133b76f48eae654007b69 is still unread. I am getting the id from the id field of the response from

https://theoldreader.com/reader/api/0/stream/items/ids?output=json&s=user/-/label/comics&xt=user/-/state/com.google/read

I think the id is good based on the fact that when I fetch the content with

https://theoldreader.com/reader/api/0/stream/items/contents?output=json&i=51d133b76f48eae654007b69

it is the content I expect.

@krasnoukhov
Copy link
Contributor

Are you sure you are sending parameters as x-www-form-urlencoded? Unfortunately multipart/form-data isn't supported.

@cowens
Copy link
Author

cowens commented Jul 1, 2013

No, I was taking whatever the default was. I will try again when I am in
front of a computer. There is still the issue of sending a response that
says "OK" when nothing has been done. I would have expected an error like
"can't find id parameter, is your request x-www-form-urlencoded?"
On Jul 1, 2013 5:28 AM, "Dmitry Krasnoukhov" notifications@github.com
wrote:

Are you sure you are sending parameters as x-www-form-urlencoded?
Unfortunately multipart/form-data isn't supported.


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-20271436
.

@cowens
Copy link
Author

cowens commented Jul 1, 2013

Yep, that seems to work. So the bug is that you say OK when you shouldn't,
not that marking as read doesn't work.
On Jul 1, 2013 5:28 AM, "Dmitry Krasnoukhov" notifications@github.com
wrote:

Are you sure you are sending parameters as x-www-form-urlencoded?
Unfortunately multipart/form-data isn't supported.


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-20271436
.

@krasnoukhov
Copy link
Contributor

Sure, you are right, I've added parameters verification with corresponding error results.

@DanielSundberg
Copy link

This was closed over a year ago as fixed. However, I still get 'ok' as result but no error message trying the same command as in the initial post.

@jfiorato
Copy link
Contributor

Would you be able to send your code so we can investigate?

@DanielSundberg
Copy link

DanielSundberg commented Dec 25, 2017

Yes I know, very late to get back 2 years later. having another go at this and is stuck at the same place:

markAsRead(auth: string, id: string) {
    const params = {
        // output: 'json',
        a: 'user/-/state/com.google/read',
        i: 'tag:google.com,2005:reader/item/' + id
    };
    let path = '/reader/api/0/edit-tag';
    const contentParams = this.serialize(params);
    const itemContentUrl = path + '?' + contentParams;
    let response = fetch(itemContentUrl, {
        method: 'POST',
        headers: new Headers({
            'Accept': 'application/json',
            'Content-Type': 'application/json',
            'Authorization': 'GoogleLogin auth=' + auth,
        }),
    });
    return response;
}
private serialize(obj: {}) {
   var str = [];
   for (var p in obj) {
        if (obj.hasOwnProperty(p)) {
            str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
        }
    }
    return str.join('&');
}

image

localhost:3000 proxies calls to The Old Reader, works for all other API calls so guess this is not the problem.

@DanielSundberg
Copy link

Looks like the params should be in the body, thought I tried that but must have gotten something wrong that time, this code is working:

    async markAsRead(auth: string, id: string) {
        const bodyParams = { 
            a: 'user/-/state/com.google/read',
            i: 'tag:google.com,2005:reader/item/' + id,
        };
        let path = '/reader/api/0/edit-tag';
        let response = fetch(path, {
            method: 'POST',
            headers: new Headers({
                'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
                'Authorization': 'GoogleLogin auth=' + auth,
            }),
            body: this.serialize(bodyParams)
        });
        return response;
    }

@DanielSundberg
Copy link

I still think that I should not have gotten OK in my snippet above. Took my some hours to figure this out.

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

No branches or pull requests

4 participants