• Michał Bajdek
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
I have following code:
Http httpProtocol = new Http();
            HttpRequest request = new HttpRequest();
            system.debug(logginglevel.INFO , '$$ ' + ValueProvider.constructEndpoint(addressToDetermineCoordinates));
            String endpoint = ValueProvider.constructEndpoint(addressToDetermineCoordinates);
            System.debug(Logginglevel.INFO , '#$ endpoint url: ' + endpoint);
            request.setEndpoint(endpoint);
            request.setMethod('GET');
            HttpResponse response = httpProtocol.send(request);
            system.debug(logginglevel.info , '## ' + response.toString() );
            
            System.debug(logginglevel.info , '@#response' + response.getBody());


            
And I am trying to send request to google maps api and recieve an answer as JSON. My variable "endpoint" contains following value:

https://maps.googleapis.com/maps/api/geocode/json?address=Lodz Tuszynska 101/7&key=[myAPIKey]

and when I am trying to do it manually via FIrefox i get proper JSON representation, but in apex I get: "12:41:58:073 USER_DEBUG [17]|INFO|## System.HttpResponse[Status=Bad Request, StatusCode=400]" . I have tried to replace all spaces to "%" in my endpoint but it did not work. COuld you please give me some advice what I am doing wrong?
Hello, I am trying to insert new custom object via REST call (POST method). I have authentication_token from salesforce callback and I attached also as request header:
User-added image

I did many attempts, but I am not able to establish connection. What I am doing wrong?
I have following code:
Http httpProtocol = new Http();
            HttpRequest request = new HttpRequest();
            system.debug(logginglevel.INFO , '$$ ' + ValueProvider.constructEndpoint(addressToDetermineCoordinates));
            String endpoint = ValueProvider.constructEndpoint(addressToDetermineCoordinates);
            System.debug(Logginglevel.INFO , '#$ endpoint url: ' + endpoint);
            request.setEndpoint(endpoint);
            request.setMethod('GET');
            HttpResponse response = httpProtocol.send(request);
            system.debug(logginglevel.info , '## ' + response.toString() );
            
            System.debug(logginglevel.info , '@#response' + response.getBody());


            
And I am trying to send request to google maps api and recieve an answer as JSON. My variable "endpoint" contains following value:

https://maps.googleapis.com/maps/api/geocode/json?address=Lodz Tuszynska 101/7&key=[myAPIKey]

and when I am trying to do it manually via FIrefox i get proper JSON representation, but in apex I get: "12:41:58:073 USER_DEBUG [17]|INFO|## System.HttpResponse[Status=Bad Request, StatusCode=400]" . I have tried to replace all spaces to "%" in my endpoint but it did not work. COuld you please give me some advice what I am doing wrong?