How to edit feature image with XML RPC?

In order to have your post have a default image, you need to set your post thumbnail. In doing this you need to set the ID of the media, which isn’t readily apparent.

I do most of my work in Python, so for me, the following helps:

Step 1. Get the list of all your media so you know the IDs

##
## Retrieve a list of media

# curl -X OPTIONS -i http://demo.wp-api.org/wp-json/wp/v2/posts
import json
import pycurl
import re
from io import BytesIO
import pandas as pd
import datetime
import urllib3


wpUrl = "https://MyWordPRessSite.COM</wp-json/wp/v2/media?page={}"

bContinue = True
page=1
while bContinue == True:
    buffer = BytesIO()
    c = pycurl.Curl()
    c.setopt(pycurl.SSL_VERIFYPEER, 0)
    c.setopt(c.WRITEDATA, buffer)
    c.setopt(c.HTTPHEADER,['Content-Type: application/json'])

    myUrl = wpUrl.format(page)
    #print(myUrl)
    c.setopt(c.URL,myUrl)
    c.perform()

    page+= 1
    if buffer != None:
        myData = json.loads(buffer.getvalue())
        for foo in myData:
            print("MediaID ={}, caption = {}, alt_text={}".format(foo["id"], foo["caption"], foo['alt_text']))
            #print(foo)
        if len(myData) <= 0:
            bContinue = False
    else:
        bContinue = False
    c.close()

Step 2. Create the post with the correct media ID

######################################################
# Create A Post
######################################################
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.posts import NewPost

#authenticate
wp_url = "https://info-qa.cloudquant.com/xmlrpc.php"
wp_username = "My_User_ID_on_WP"
wp_password = "My_PWD_on_WP"


wp = Client(wp_url, wp_username, wp_password)

#post and activate new post
post = WordPressPost()
post.title="3 Post"
post.content="<h1>heading 1</h1>Tayloe was here<br><small>here too!</small><p>New para."
post.post_status="draft"
post.thumbnail = 50  # The ID of the image determined in Step 1
post.slug = "123abc"
post.terms_names = {
  'post_tag': ['MyTag'],
  'category': ['Category']
}
wp.call(NewPost(post))