I’ve got this little shortcode

function starlight_count() {
$url = 'https://herokuapp.com/creditcount?contact_id=' . do_shortcode('[i4w_db__FirebaseID]');
$response = wp_remote_get( esc_url_raw( $url ) );
$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
$response_message = wp_remote_retrieve_response_message( $response );

ob_start(); ?>
    echo $url;
echo $response_message;
    print_r($response); ?>
    return ob_get_clean();

add_shortcode( 'starlight-count', 'starlight_count' );

The first echo returns


But the actual call returns a 500 error, and is trying to request data from

[url] => https://herokuapp.com/creditcount?contact_id=%5Bi4w_db__FirebaseID%5D

Why isn’t it using the merged data URL?

Read more here: Why isn’t the URL the same for echo and for response in WordPress Remote


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: