Weather APIs Integration | Named Credentials & External Credentials in

Поделиться
HTML-код
  • Опубликовано: 7 янв 2025

Комментарии • 45

  • @amrutninawe3154
    @amrutninawe3154 Год назад +2

    Awesome content for Integration learners...
    Thankyou

  • @yatin1370
    @yatin1370 11 месяцев назад +1

    Precise and to the point. Wonderful tutorial to exercise LWC and Integration topics at the same time.
    Just an observation: If we don't give anything in input and press the button we still get 'Sunny' climate. I verified this a lot of times.
    To fix this, I rephrased the apex method as follows and now it gives error when nothing is given in input and still weather is searched:
    public static string getWeather(String city){
    if (city != null) {
    Http http = new Http();
    HttpRequest request = new HttpRequest();
    request.setEndpoint('callout:WeatherAPI/current.json?q='+city);
    request.setMethod('GET');
    HttpResponse response = http.send(request);
    if (response.getStatusCode() == 200) {
    return response.getBody();
    }
    }

    return '';
    EDIT 2: I also fixed searching weather for cities where there are two words...for eg: "New York" or "Los Angeles" which does not work with current code. I used regex for this in Javascript.
    I added a property 'encodedInputText' in the JS file and also tweaked the buttonClick function as below:
    buttonClick(event){
    //REGEX for considering the spaces given in the input and spaces in City Name
    const input = this.template.querySelector("lightning-input").value;
    const regex = / {2,}/g;
    const correctedInput = input.replaceAll(regex, " ").trim();
    this.encodedInputText = encodeURI(correctedInput);
    getWeather({city : this.encodedInputText})
    .then((response)=>{
    console.log("in then");
    //parse received JSON
    let parsedData = JSON.parse(response); >>>> Rest is same >>>>>

  • @adwit511
    @adwit511 Год назад +2

    The best channel for sfdc newbies!!

  • @ravindrasutar5041
    @ravindrasutar5041 Год назад +1

    Helpful
    Thanks

  • @dnyaneshwarkakad5191
    @dnyaneshwarkakad5191 Год назад +2

    Just Awesome content 👍👍

  • @SubhasiniVM
    @SubhasiniVM Год назад +1

    Thanks for the good video. Please share video a beginner how to start working in integration

  • @ikec7941
    @ikec7941 Год назад +5

    If your hardcoding key into custom header, principal becomes redundant since it's meant to refered using merge field syntax in custom header value to hide secrets.

    • @SalesforceBolt
      @SalesforceBolt  Год назад +1

      Thanks for noticing it. Yes I agree, I missed it in video but added it in the blog post for the same.
      www.salesforcebolt.com/2023/07/weather-apis-integration-named.html

    • @ikec7941
      @ikec7941 Год назад

      Great 👍 Thanks

  • @chandu5645
    @chandu5645 Год назад +4

    Very informative. Can you please also a make a complete video on Named credentials with OAuth 2.0. It's really confusing 😟

    • @SalesforceBolt
      @SalesforceBolt  Год назад +1

      Yes it is confusing, I am planning a separate video as well!

    • @Adrift98
      @Adrift98 Год назад

      ​@@SalesforceBoltis the video out?

    • @ghoshdipan
      @ghoshdipan 4 месяца назад

      @@SalesforceBolt Is the video out now???

  • @kishoreveeran383
    @kishoreveeran383 Год назад +2

    Appreciate you work helpful for me , i have request one video about lightning datatable. in datatable how to apply type attribute so the values comes as same sized button irrespect of length looking forward for that videos

  • @ChandraYetukuri-v4w
    @ChandraYetukuri-v4w Месяц назад

    Hi Kapil, the video is very informative. Could you please let us know how the same can be re authorized using OAuth 2.0 instead of custom.

  • @ujjwalsharma3285
    @ujjwalsharma3285 Год назад +1

    Hi,
    Great stuff!
    If possible can you create or suggest series on salesforce integration? Videos on youtube are little confusing and don't implement end to end. Most of the videos just demo using postman.

  • @ChandraYetukuri-v4w
    @ChandraYetukuri-v4w Месяц назад

    @Salesforce Bolt I just tried this in my org. It gives an error if the city has two words. For New York, Abu Dhabi are giving error. Single word cities are fine.

  • @Shaik_Abdul_01
    @Shaik_Abdul_01 10 месяцев назад +1

    Hi @Salesforce Bolt, Thanks a million for sharing useful Content. Iam encountering an error "API Key is disabled ", Could u pls guide me How to resolve it.

    • @SalesforceBolt
      @SalesforceBolt  10 месяцев назад

      Hi are you still having the same issue?

    • @ChandraYetukuri-v4w
      @ChandraYetukuri-v4w Месяц назад

      @@SalesforceBolt @Shaik_Abdul_01 it could be because the API key would have expired. Its only valid for few weeks i guess..

  • @premnaathNJ
    @premnaathNJ 3 месяца назад +1

    i subcribed today, to search any datacloud integgration, is it possible?

    • @SalesforceBolt
      @SalesforceBolt  3 месяца назад

      Thanks for the subscribe. Data Cloud integrations will be coming soon.

  • @NagulaMallika
    @NagulaMallika 25 дней назад +1

    Hi @salesforcebolt can you guide me the steps

    • @SalesforceBolt
      @SalesforceBolt  23 дня назад

      You can find the steps here
      www.salesforcebolt.com/2023/07/weather-apis-integration-named.html

  • @leosalles5338
    @leosalles5338 2 месяца назад

    i dont know why, but my icon doesn't load...but if i open the image in a new tab, i can see it.

    • @SalesforceBolt
      @SalesforceBolt  Месяц назад

      Is it coming from the same URL that you must have added in your named credentials?

  • @dattasoham
    @dattasoham 10 месяцев назад +1

    Opencage API is not working using Named Credential and External Credential

  • @TK-vt3ep
    @TK-vt3ep Год назад

    How do certification works here?

    • @SalesforceBolt
      @SalesforceBolt  Год назад

      Can you please elaborate your questions?

    • @TK-vt3ep
      @TK-vt3ep Год назад

      @@SalesforceBolt so i have to use https end point to generate token which i will use as bearer authorization for subsequent callout of api’s. Now i am configuring named credential with external credential but then it keeps giving me 503 error, later on it was brought up that the cert i have in named credential should be client cert. So how do i use that now? The api team gave the cert but how do i use for my named credential? I know i have to import it under certifications but do i need to make changes in my apex code too for using that cert?

  • @ChandraYetukuri-v4w
    @ChandraYetukuri-v4w Месяц назад

    The error was rectified by changing the code as below....
    String encodedCity = EncodingUtil.urlEncode(city, 'UTF-8');
    req.setEndPoint('callout:WeatherAPI/current.json?q='+encodedCity);

  • @anupambasak2000
    @anupambasak2000 Год назад +1

    Error: System.NullPointerException: Attempt to de-reference a null object
    Error: Class.Weather.getWeather: line 28, column 1
    AnonymousBlock: line 1, column 1
    AnonymousBlock: line 1, column 1
    59.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO
    Execute Anonymous: Weather.getWeather('London');
    Why is this error coming?

    • @SalesforceBolt
      @SalesforceBolt  Год назад

      Have you copied the exact code from code snippet?

    • @anupambasak2000
      @anupambasak2000 Год назад +1

      Hi@@SalesforceBolt! Previously it worked for me... I fetched data also... But today I tried again but it is showing me ------ response: {"error":{"code":1002,"message":"API key is invalid or not provided."}}

    • @SalesforceBolt
      @SalesforceBolt  Год назад

      @@anupambasak2000 please check the key if it got expired.

    • @anupambasak2000
      @anupambasak2000 Год назад

      @@SalesforceBolt It wasn't expired... My bad I used other name in Custom Headers... Later it worked... But could you try using OpenWeatherMap API and NewsAPI with External Named Credentials? I was integrating these but it was not working... Finally I did using Custom Metadata but how to do with External Credentials, I'm still desperate to know...