Watch your keys:
$headers = array(
// 'headers' => array( // this is duplicated
'Authorization' => 'Basic ' . base64_encode( 'username:password' ),
'Accept' => 'application/xml'
// )
);
$res = wp_remote_request(
$url,
array(
'method' => 'GET',
'headers' => $headers
)
);
Don’t send headers
inside headers
. Using a variable name different from args
can help you spot the issue.
Example reference in docs:
https://developer.wordpress.org/plugins/http-api/#get-using-basic-authentication
Related Posts:
- x-wp-nonce is not allowed by Access-Control-Allow-Headers in preflight response
- WordPress REST API “rest_authentication_errors” doesn’t work external queries?
- Passing a borrowed nonce through Postman fails
- WP_REMOTE_POST Requests are being blocked by API provider [closed]
- Get all PDF files from page with WordPress API
- “No Access-Control-Allow-Origin header is present” even though it is in the entry file
- Validate rest-api call on create
- Get a remote post ID via API given URL
- How to change the date and time in REST API for comments?
- WordPress HTTP API NTLM Authentication
- [Zapier + WP Webhooks Pro]: Custom Fields get cut off at first comma or semicolon
- REST API and filtering by meta value
- Rest API: trouble receiving response through script (browser and Postman display correctly)
- Is there a way I can fetch the WordPress Developer Code References with an API?
- How to display relations via wordpress Rest API
- How to add Relations of a CCT from JetEngine via WordPress Rest API
- Can I overwrite default WordPress Json API For no more pages text
- trigger WordPress rest any API call
- Secure WordPress API, how?
- register/login api
- WordPress REST API in Integromat: How to overcome “Sorry, you are not allowed to list users / edit this…”
- how to create JSON array [] for REST response?
- Remove unwanted fields from WP API response
- How to receive JSON payload from a digital device
- The REST API encountered an error in wordpress?
- WordPress API “code”:”rest_no_route” with Custom Route
- Connecting WordPress with an External API
- WordPress single page website redirect to index.html
- Autotrader API Integration
- REST API get featured image source for custom post type
- Update post / page using API + python
- JS WordPress API fetch no response headers
- Issue with API after 6.2 update
- Woocommerce API for calling products by Category ID
- How to use WP-REST API to login user and get user data for Android app?
- How do I cache (core) API requests?
- WP REST API returns blank response if post is too long
- Increase per_page limit in REST API
- How to feed a HTML5’s EventSource with a REST API custom endpoint?
- Retrieve CSS and JS From the REST API
- How to stop WP API endpoint from caching?
- How to Authenticate WP REST API with JWT Authentication using Fetch API
- WordPress 4.7 REST API endpoints
- Headless WordPress: How to authenticate front end requests?
- REST API multiple media upload
- 401 Error when trying to make a REST API call to site
- Developing Themes with React/Angular
- Does jQuery/Ajax send cookies when using the rest API or do I need to somehow add them?
- Can we access the REST request parameters from within the permission_callback to enforce a 401 by returning false?
- Upload image to wordpress using REST API
- Can I define multiple callback methods depending on the call method?
- Filter post content in REST API
- Create post with REST API in php with file_get_contents
- How add meta fields to a user with the wp-api?
- WordPress Rest API response
- WP Rest API not working
- Request to REST endpoint works fine in browser and curl, but fails from WP_REST_Request
- WP REST api.wordpress.org discovery
- How can I cache WordPress Rest API Response
- Why does AWStats show /wp-json* as Viewed URLs
- How do you format the set_body option for WP_Rest_Request?
- featured image not found in json from wp rest api
- is it possible to filter a rest api endpoint by using a registered rest field?
- Ho to style post content for WordPress API?
- rendering view in backbone
- Update a post based on results from GET request to another server
- Manipulating/view postmeta remotely
- Check authentication credentials using WP REST API
- WordPress REST API V2: how to get list of all posts?
- Getting 401 from ajax using an application password
- How to connect android app with WordPress website?
- WordPress REST API calls that depend on the WordPress User
- How to get data from /wp-json/wp/v2/users/me
- I can’t post comment via REST API
- WordPress REST API parameters are not affecting a response
- Update meta_value in wp_postmeta using API
- Multisite WP-API json v2 : can i fetch all comments on all sites with a single query?
- WordPress plugin with CORS
- /wp-json/wp/v2/posts/?app=3 is returning random scripts tags
- User following system via REST API
- “Error: cURL error 60: SSL certificate problem: certificate has expired” when create product in WooCommerce via REST API
- How to use WordPress REST api to login a user?
- Wrong encoding of dynamic block properties problem when loggen in as editor
- Need wp rest api for featured video post
- WordPress output data to another website and pull data
- Set logged in user based on API response
- REST api header link href
- WordPress & React Native
- Is it possible to combine two rest endpoints in the url?
- update meta data (like view counter) by rest-api
- Rest API hook ‘rest_insert_post’ not returning request object
- How to display parent category with first level child in REST API
- How Can I keep password protected posts in the json requests but not on frontend queries?
- How to use WordPress rest API with Angularjs 4 [closed]
- Rest API User Levels
- Retrieve posts by page in wp rest api
- Script tag in string in wordpress rest api body to create post
- Customizer Changeset, Sidebar and Rest API Custom Endpoints
- Auto generating API keys using the Application Authentication Endpoint [closed]
- Uploading media to wordpress API with C# HttpClient