I tried some more trial and error and managed to get it to work by simply putting $xml as the body without specifying it as an array. The function reference says, “Post data should be sent in the body as an array,” so I’m not sure why it worked.
Here is the working code in case it helps someone else:
// Sends the xml request to the API
$result = wp_remote_post(
$this->settings['api_url'],
array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.1',
'headers' => array(
'Content-Type' => 'text/xml'
),
'body' => $xml,
'sslverify' => 'false'
)
);
Related Posts:
- $wpdb -> Batch insert from XML File?
- Does WordPress’s HTTP API use any caching?
- How to convert this cURL to wp_remote_get?
- Using WPDB to output raw XML fails because of wp-blog-header.php
- Failed to Open Stream: Permission Denied While Writing to an XML File in a WordPress Plugin
- Add information to HTTP Header in WordPress Plugin
- How to set a header in wp_safe_remote_get()?
- What method should I use to store my plugin data (multi level menus with options on each item)
- mysql_real_escape_string() error using xml2ary in WordPress plugin
- Safe XML response from wordpress plugin
- $_POST form request with admin-post
- How can I configure Docker for developing and deploying a custom theme?
- Add screen options to custom admin pages
- How can I run AJAX on a button click event?
- Completely remove WP_Admin_Bar for specific user roles
- WordPress and PHP Sessions – Security and Performance
- What is the difference between using global $current_screen and get_current_screen()?
- How to make repeated component/block in Gutenberg
- Must-use plugins autoloader: How to use get_plugins() correctly?
- Changing upload directory for plugin uploads only
- How Do I Make WordPress Run an Event Every Day?
- How can I change the frequency of a scheduled event?
- How to filter $post->post_content prior to save
- How to get data from WordPress $wpdb into React Gutenberg Blocks Frontend?
- How to check if certain plugin exists and in expected version
- Why won’t register_setting() create a setting?
- One time username change from frontend?
- Customizer Not Saving Options
- How to add SQL file with PHP to WordPress database [closed]
- How to extend a plugin like we do a theme?
- How to add custom text in wordpress logs
- Rewrite url for existing page without flush_rewrite_rules
- Does add_filter work outside functions.php
- Is it possible to modify the media library admin screen?
- What function to hook for changes made in status and visibility of a post
- In woocommerce who is responsible for sending the receipt email?
- How to restore WP 5.4 behaviour where a numeric string could added to each page URL and parsed as “page” in WP 5.5?
- Block: attributes not saving
- Callback function is being called twice
- async code or cron job?
- Plugin development: How many plugin and WordPress version combinations to support?
- Hook to get image filename when it is uploaded
- Clearing cached plugin data if it is using an external object cache
- WordPress not working on localhost
- Custom delete option button in plugin settings
- wp_scheduled_event being removed mysteriously
- Sub Menu content is being duplicated
- how to append custom metabox field with the ACF custom fields id in wordpress development
- $_FILES empty on created_{taxonomy} and create_{taxonomy} yet is is not on edit_{taxonomy}
- Memberpress Hooks and Activity
- Adding fields to category manager. Does a method exist to get the link to the category edit screen?
- How to test a WordPress plugin in real time
- Distributing Frontend Assets with Plugins
- Wp-admin Custom User Management
- Can we intercept user_login and user_pass from a wp_login_form?
- Hook add_attachment error
- Undefined variable’s error when expected to have passed the content of variable [closed]
- How do I find the page/url where a search came from when using pre_get_posts filter?
- Shortcode conflicts
- How can I add rewrite rules to a class-based plugin?
- hook update_option/updated_option empty $old_value and $value
- Issues Updating Post Meta with AJAX (Seems simple but cannot figure it out)
- How to output functions from plugin inside theme
- Sharing Variables between scheduled events
- Issue with plugin sub menu and pages
- Using delete_post_meta for deleting multiple selected options
- Workflow for new importer plugin – your advices?
- Should I put my plugin javascript inline?
- Can / should a widget plugin define its own Widget Area?
- How to automatically activate a plugin on install
- disable defaault wordpress comments from a plugin
- How to get the `comment_post_ID`?
- Can someone explain what’s the use of parse request function in WordPress?
- Add parameters to 3rd party callback function
- add_editor_style to the blog editor view (Gutenberg?)
- How does update method in Widget class saves $instance array from Select tag?
- jQueryUI draggable doesn’t work in WordPress plugin
- call funcution when clicking submit
- WooCommerce – Stop assigning order numbers
- How can I pass WP_Query results to a plugin?
- How to prevent users from deleting their accounts?
- How do I get a reference to the HTML memory buffer while the page is being constructed?
- WC_Geolocation not found inside plugin
- Set widget icon in Customizer?
- How to customize the size of Featured Images or Post Thumbnails in WordPress?
- add_option_{$option} action hook not being called
- Remove all capabilities in separate method fails versus included in method
- Hook for plugin to show content for certain urls
- Why does unzip_file always return true but nothing happens?
- Let user override plugin CSS
- What happens when you create/edit a menu
- Add_menu_page and saving settings
- Updating Style From WP Options Setting Page
- add short code not working
- What method would I use to show an image in between X amount of posts on category archive? [duplicate]
- Shortcode attribute “title” doesn’t appear in $atts array
- Plugin – Proper way to handle 404 pages?
- Find Any Theme’s page.php File
- WP Job Manager – Show recent jobs as cards
- Admin Menu for New Post