DEV Community

Connecting to WordPress using C#

Yeison Lapaix on September 20, 2018

In this post, we will see how to connect to a Wordpress website using C# and make publications using the WordpressPCL library in three easy step...
Collapse
 
whitear27 profile image
Audrey White

Hi, this post has been super helpful to me. I am a student developing a Xamarin iOS app for a current Wordpress WooCommerce site. I was able to retrieve the products and display within the app. I can also add products, however I am unable to upload images from my iPhone into the WordPress wp-content library. Is there a way to upload images directly to the wp-content media library with WordPress PCL?
Thank you for this post!

Collapse
 
yeisonpx profile image
Yeison Lapaix

Hi Audrey, thanks to you for your feedback. You can upload images using the client.Media object and methods. For example:

 var createdMedia = await client.Media.Create(@"C:\pathToFile\media.jpg","media.jpg");

Check more details here in the documentation: Working with Medias

I hope this can help you.

Collapse
 
mohammedtuhami330 profile image
MohammedTuhami330

I want to connect using application password !
can i ?

Collapse
 
mohammedtuhami330 profile image
MohammedTuhami330

Object reference not set to an instance of an object" mean?

Collapse
 
esklad profile image
esklad

When I connect to your site:
demo.wp-api.org/wp-json/
everything is working!
And when to my: bonito-market.ru/wp-json/
That get an error:
Unexpected character encountered while parsing value: p. Path ', line 0, position 0.
What would that mean ?!

Collapse
 
esklad profile image
esklad

With the new version of WordPress, your WordpressPCL library is not working. As in the new version of WordPress returns not JSON, but HTML!
According to the Wireshark
It's true?

Collapse
 
rmehling profile image
Robert Mehling

This worked great for me. Thank you very much for sharing!

Collapse
 
cognicsystems profile image
Cognic

Hello @yeisonpx
Thanks for the article, Drawing inspiration from your post, we have restructured the process to align with the latest conditions , please take a look and let me know your thought.

Collapse
 
esklad profile image
esklad

And one more question:
Does your "WordpressPCL" work with Products and WooCommerce (Orders)?

Collapse
 
yeisonpx profile image
Yeison Lapaix

Hello, thanks for your response.

I never try with WooCommerce, but I suppose products are post types and you can try publishing a post with setting the property of Type with Product.

First consult the posts with the WordpressPCL library and then check if also retrieve the products and which type of post is.

Let me know if that work for you.

Collapse
 
esklad profile image
esklad

The programmer did not solve the problem:
studiofreya.com/2018/06/04/problem...