How upload image via API (v1/attachments)

I need to add pictures to ads via API
I’m trying this method Upload an attachment | HivePress REST API documentation
This is the right method?

I tried different things but got error.
responce: {‘error’: {‘code’: 400}}
or
{‘code’: ‘rest_invalid_json’,
‘data’: {‘status’: 400,
‘json_error_code’: 4,
‘json_error_message’: ‘Syntax error’}}

I tried to transmit file as image and as text (base64)

if I use /wp-json/wp/v2/media I can upload an image but it will not fit the size of the ad template

I tried other methods and it worked (/wp-json/hivepress/v1/listings/{listing_id})

I use python.
How can l use this method: post v1/attachments?

Thanks for the answer

1 Like

Sorry for the delay. Please check the request example here, it’s sent by the file upload JS script https://github.com/hivepress/hivepress/blob/master/assets/js/common.js#L642 I’m not sure about the file format it sends, it’s probably in base64.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.