How to relate an image to an article when posting the article in REST API Using the following code we can post a node trough rest API. However, if there is an image attached to this article we need to post the image node first and then include the image fid in the article.I successfully posted the image also but as far as the documentation is very incomplete I am not able to find a way to add the image fid to the second request to attach it to the article.

$serialized_entity = json_encode([
   'title' =&gt; [['value' =&gt; $node-&gt;title]],
   'body' =&gt; $node-&gt;body_array,
   'type' =&gt; [['target_id' =&gt; $node-&gt;node_type]],
   '_links' =&gt; ['type' =&gt; [
       'href' =&gt; $base_url.'/rest/type/node/'. $node-&gt;node_type
    ]],
]);

$response = \Drupal::httpClient()
    -&gt;post($base_url.'/entity/node?_format=hal_json', [
        'body' =&gt; $serialized_entity,
        'headers' =&gt; [
            'Content-Type' =&gt; 'application/hal+json',
            'Authorization' =&gt; 'Bearer '. $token-&gt;access_token
        ]
    ]);


Is this the right way to attach an image? if yes, what are the request parameters we need to add the image to the node post request? 

Any help would be appreciated.
Thanks
See https://www.drupal.org/project/drupal/issues/1927648, this is not supported yet in core.

You can try using https://www.drupal.org/project/better_normalizers to send it base64 encoded instead.