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

I Can not Connect To My Rest Api Website #71

Closed
adelhoss opened this issue Oct 25, 2017 · 4 comments
Closed

I Can not Connect To My Rest Api Website #71

adelhoss opened this issue Oct 25, 2017 · 4 comments

Comments

@adelhoss
Copy link

hi thx for helpful Library
I can not connect to rest api my web site
worpress version is : 4.8.2
and this link : http://marjafile.com/wp-json/ has exist
i install jwt and enable header and added my token
when i use this code
var client = new WordPressClient("http://marjafile.com/wp-json/"); await client.RequestJWToken("admin", "passadmin"); var posts = await client.Posts.GetAll();
always return 0 post and null

@ThomasPe
Copy link
Member

hi,
did you block the public access to your /posts endpoint?
If so you'll have to explicitly tell the client to use authentication when calling the API
var posts = await client.Posts.GetAll(false, true);
the first parameter "embed" will tell the method whether posts should include linked elements like featured images. The second one is the authentication flag (you'll want to use true here).

@polushinmk
Copy link
Contributor

polushinmk commented Oct 26, 2017

Yes http://marjafile.com/wp-json/wp/v2/posts/ return 403 Forbidden, so your site blocks posts endpoint.
But I find another issue - your date time culture format arabic with custom format (strings, not numbers).
date=۱۳۹۵-۱۲-۲۴ ۱۴:۵۶:۲۶ +۰۰:۰۰
our deserializer cannot deserialize that date correctly.
Could you tell me your culture info from this https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo(vs.71).aspx
and your datetime format from WordPress Settings?
@ThomasPe I think we should add option to customize JsonDeserialization settings.

@ThomasPe
Copy link
Member

Sure, we could certainly pass a settings object when creating the client.

@polushinmk
Copy link
Contributor

@adelhoss Could you send me your culture info and datetime format from WP settings? It is necessary for debug

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

No branches or pull requests

3 participants