function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
oski93oski93 

Method does not exist or incorrect signature: void getHeaderKey(String) from the type System.HttpResponse

Hi folks, 

This seems like a weird one (must be dead simple, but not seeing it).

I'm simply trying to access an Http response header key value as specified in the docs, When I try to save, the compiler is complaining about the method signature. I've tried in a few different orgs to make sure somehow the HttpResponse class hadn't been overridden somehow...

Thanks for any clues/suggestions.
public class HttpTesting {
    public HttpTesting() {
        String aString = 'aHeaderKey';
        HttpRequest anHttpRequest = new HttpRequest();
		HttpResponse anHttpResponse = new Http().send(anHttpRequest);

        System.debug('---> anHttpResponse.getHeaderKeys(): ' + anHttpResponse.getHeaderKeys());
        System.debug('---> anHttpResponse.getHeaderKey(aString): ' + anHttpResponse.getHeaderKey(aString));  // <--- 'Method does not exist or incorrect signature: void getHeaderKey(String) from the type System.HttpResponse'
    }
}

 
Best Answer chosen by oski93
Aslam ChaudharyAslam Chaudhary
Yes I am able to save using belolw code
System.debug('---> anHttpResponse.getHeaderKey(aString): ' + anHttpResponse.getHeader(aString));  // <--- 'Method does not exist or incorrect signature: void getHeaderKey(String) from the type System.HttpResponse'



 

All Answers

oski93oski93
Hi Aslam,

I already mentioned (and looked at) this documentation link.

I'm simply finding that I'm unable to save/compile the getHeader(String key) method at all, and get the compiler error I mentioned in my post.

Are you able to save the class that I posted in your org without any error?

Thanks.
Aslam ChaudharyAslam Chaudhary
Yes I am able to save using belolw code
System.debug('---> anHttpResponse.getHeaderKey(aString): ' + anHttpResponse.getHeader(aString));  // <--- 'Method does not exist or incorrect signature: void getHeaderKey(String) from the type System.HttpResponse'



 
This was selected as the best answer
oski93oski93
Thanks Aslam... Sorry, was staring at my screen for waaay too long when I was looking at this.