wp-net / WordPressPCL

This is a portable library for consuimg the WordPress REST-API in (almost) any C# application
MIT License
340 stars 130 forks source link

Delete client #305

Open giulianoviale opened 2 years ago

giulianoviale commented 2 years ago

Hello! im having trouble when I want to delete a client .. when i wanna make a query to search for the user with an email string parameter to know if the user exist it doesnt work , any advise?

navjot50 commented 2 years ago

Could you post the code snippet you have tried? Also, at this point it is not clear from your wording what are you actually trying to acheive.

giulianoviale commented 2 years ago

snippet I want to know if this is possible, searching with .Search passing the string of the email, knowing this I can get the ID for the parameter of the .Users.Delete() method

navjot50 commented 2 years ago

Does it throw any exception?

giulianoviale commented 2 years ago

None

giulianoviale commented 2 years ago

you understand what i wanna accomplish? maybe i can express myself better

navjot50 commented 2 years ago

There should be no problem if you pass the email in the Search of UsersQueryBuilder. However, the Wordpress REST api only returns the users which have created at least one post, page or category (or so to say any kind of content in Wordpress). If the user you are searching for hasn't created anything in Wordpress, then it will not be returned in the result.

giulianoviale commented 2 years ago

image im trying that , it retrieves all mi clients but doesnt give the their emails , i have something like 2769 users and only retrieve 10 with the email propertie image

giulianoviale commented 2 years ago

Can you lead me to some example of the use of the Search in the query builder?

navjot50 commented 2 years ago

The result of UsersQueryBuilder is paginated by default. It gives 10 results for one request. You can set the Page and PerPage properties of UsersQueryBuilder to loop through and retrieve all users. Max value for PerPage is 100. So, one query can return at max 100 users.

giulianoviale commented 2 years ago

Please give me more information of the Search sentence and how to do it

navjot50 commented 2 years ago

You can have a look at the REST api reference from Wordpress: https://developer.wordpress.org/rest-api/

My general advice would be to first try the query builder. If you get a specific exception and problem then it would be easier to help you.

giulianoviale commented 2 years ago

image

I dont have any exception or problem, i just wanna retrieve and save all the users from the query that i´ve build, i dont know how to make a for each of the 10 pages that retrieve me 100 users each one, if you can help me with that it would be all that i need at the moment

navjot50 commented 2 years ago

Use a for loop and increment the Page property for each iteration of for loop.

Have a look here: https://github.com/wp-net/WordPressPCL/issues/297#issuecomment-1056736599

giulianoviale commented 2 years ago

Thank you, i´ll be updating you from this

giulianoviale commented 2 years ago

image JWT Authentication for WP REST API is configured correctly, when i want to do the .RequestJWToken method it throws me that error, on line 35

navjot50 commented 2 years ago

Try generating JWT token using Postman. If it doesn’t generate token there, then the JWT plugin is not configured properly.

giulianoviale commented 2 years ago

Try generating JWT token using Postman. If it doesn’t generate token there, then the JWT plugin is not configured properly.

i´ve installed the plugin jwt and configured the wp_config.php file , im gonna try to do what you´ve told me

giulianoviale commented 2 years ago

Try generating JWT token using Postman. If it doesn’t generate token there, then the JWT plugin is not configured properly.

i´ve installed the plugin jwt and configured the wp_config.php file , im gonna try to do what you´ve told me

image it works

navjot50 commented 2 years ago

So, atleast the plugin is configured correctly. You must remove the image as it has your credentials. I would suggest you to check the base url that you are passing to the wordpress client on construction. Maybe it’s wrong and you are getting errors for that.

giulianoviale commented 2 years ago

"You must remove the image as it has your credentials." i dont undestand that the url that im passing is this one: https://portal21uat.hrfactors.online/wp-json

giulianoviale commented 2 years ago

"You must remove the image as it has your credentials." i dont undestand that the url that im passing is this one: https://portal21uat.hrfactors.online/wp-json

Any news about this issue? i think that the url works fine but i cant do the conection, how can i notice if the url works or not?

giulianoviale commented 2 years ago

I´ve check everything(including the wordpresspcl source code) and found nothing wrong