[Python] Build a CRUD Serverless API with AWS Lambda, API Gateway and a DynamoDB from Scratch

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

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

  • @dhochee
    @dhochee 2 года назад +7

    I had to add lambda/dynamodb functionality to a simple website in just a few hours and was worried I wouldn't have time, but this vid totally saved the day. Everything worked perfectly. Thanks!

    • @FelixYu
      @FelixYu  2 года назад

      Glad that it helped 👍

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

    I've followed about 6 videos before trying to get this working and was unsuccessful.
    A couple of things I took away from yours that made it successful for me:
    - Your attention to detail and explanation of the code was very helpful.
    - Setting the timeout to longer than 3 seconds I think is the golden thing that puzzled me, other videos didn't advise it, yet I think it helped!
    - Case sensitivity is important. I named my key productid instead of productId and had to use cloud watch to figure out why mine didn't work.
    - Not only does it work, I now have a code base as well as a base understanding to keep going. Massive thank you!

  • @shaneatvt
    @shaneatvt 2 года назад +7

    This is super helpful material. Your level of content and pace are great. Thanks a lot Felix!

    • @FelixYu
      @FelixYu  2 года назад +1

      Tyty glad that u found it helpful!!

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

    Hi bro, excellent video, in the first time, was desperate jejeje, because I changed some variables and put the wrong variables necessary for all the code, also, I could add all tests for every method that you mentioned in the video, was very interesting, because if you don't know how to check the logs in. cloud watch, or you don't the correct syntax to write the dynamodb resources, you always get and internal server error 502. Thanks for this video you won a follower for your channel. Note: I broke my brain, trying to fix all my errors, but this is our world, we try to understand other codes and to practice every day until all are excellent. thanks again and regards.🤓

  • @AhmedKhatib-c1w
    @AhmedKhatib-c1w 22 дня назад

    This was very straightforward and helpful. Thank you!
    Experimented with stuff and followed along and learned much.
    Just one thing, your python variable / object naming convention feels like Javascript (camelCase), while in Python the convention is variable_name.
    So was confused for a short time xD.

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

    If you are getting internal server error then make sure that the code is correct and that dynamo table name is spelt as productId (capital I not i). If you are getting a 404 not found error then make sure you have spelt your variables correctly. I had PATCH as PACH. I've provided the code written in this tutorial below:
    # lambda_function:
    import boto3
    import json
    import logging
    from custom_encoder import CustomEncoder
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)
    dynamodbTableName = "product-inventory"
    dynamodb = boto3.resource("dynamodb")
    table = dynamodb.Table(dynamodbTableName)
    getMethod = "GET"
    postMethod = "POST"
    patchMethod = "PATCH"
    deleteMethod = "DELETE"
    healthPath = "/health"
    productPath = "/product"
    productsPath = "/products"
    def lambda_handler(event, context):
    logger.info(event)
    httpMethod = event["httpMethod"]
    path = event["path"]
    if httpMethod == getMethod and path == healthPath:
    response = buildResponse(200)
    elif httpMethod == getMethod and path == productPath:
    response = getProduct(event["queryStringParameters"]["productId"])
    elif httpMethod == getMethod and path == productsPath:
    response = getProducts()
    elif httpMethod == postMethod and path == productPath:
    response = saveProduct(json.loads(event["body"]))
    elif httpMethod == patchMethod and path == productPath:
    requestBody = json.loads(event["body"])
    response = modifyProduct(requestBody["productId"], requestBody["updateKey"], requestBody["updateValue"])
    elif httpMethod == deleteMethod and path == productPath:
    requestBody = json.loads(event["body"])
    response = deleteProduct(requestBody["productId"])
    else:
    response = buildResponse(404, "Not Found")
    return response
    def getProduct(productId):
    try:
    response = table.get_item(
    Key={
    "productId": productId
    }
    )
    if "Item" in response:
    return buildResponse(200, response["Item"])
    else:
    return buildResponse(404, {"Message": "ProductId: {0}s not found".format(productId)})
    except:
    logger.exception("Do your custom error handling here. I am just gonna log it our here!!")
    def getProducts():
    try:
    response = table.scan()
    result = response["Items"]
    while "LastEvaluateKey" in response:
    response = table.scan(ExclusiveStartKey=response["LastEvaluatedKey"])
    result.extend(response["Items"])
    body = {
    "products": response
    }
    return buildResponse(200, body)
    except:
    logger.exception("Do your custom error handling here. I am just gonna log it our here!!")
    def saveProduct(requestBody):
    try:
    table.put_item(Item=requestBody)
    body = {
    "Operation": "SAVE",
    "Message": "SUCCESS",
    "Item": requestBody
    }
    return buildResponse(200, body)
    except:
    logger.exception("Do your custom error handling here. I am just gonna log it our here!!")
    def modifyProduct(productId, updateKey, updateValue):
    try:
    response = table.update_item(
    Key={
    "productId": productId
    },
    UpdateExpression="set {0}s = :value".format(updateKey),
    ExpressionAttributeValues={
    ":value": updateValue
    },
    ReturnValues="UPDATED_NEW"
    )
    body = {
    "Operation": "UPDATE",
    "Message": "SUCCESS",
    "UpdatedAttributes": response
    }
    return buildResponse(200, body)
    except:
    logger.exception("Do your custom error handling here. I am just gonna log it our here!!")
    def deleteProduct(productId):
    try:
    response = table.delete_item(
    Key={
    "productId": productId
    },
    ReturnValues="ALL_OLD"
    )
    body = {
    "Operation": "DELETE",
    "Message": "SUCCESS",
    "deltedItem": response
    }
    return buildResponse(200, body)
    except:
    logger.exception("Do your custom error handling here. I am just gonna log it our here!!")

    def buildResponse(statusCode, body=None):
    response = {
    "statusCode": statusCode,
    "headers": {
    "Content-Type": "application/json",
    "Access-Control-Allow-Origin": "*"
    }
    }
    if body is not None:
    response["body"] = json.dumps(body, cls=CustomEncoder)
    return response
    ########################################################################
    # custom_encoder:
    import json
    class CustomEncoder(json.JSONEncoder):
    def default(self, obj):
    if isinstance(obj, float):
    return float(obj)

    return json.JSONEncoder.default(self, obj)

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

      I had some problem with the CustomEncoder and had to change this :
      import json
      from decimal import Decimal
      class CustomEncoder(json.JSONEncoder):
      def default(self, obj):
      if isinstance(obj, Decimal):
      return str(obj) # Convert Decimal to a string
      return super().default(obj)

    • @rafaeldeghi587
      @rafaeldeghi587 11 месяцев назад

      Anyone had this error? Cant find a solution, its occurs when i try to use patch method, the value is updated, but the response from the api is 500
      [ERROR] UnboundLocalError: cannot access local variable 'response' where it is not associated with a value
      Traceback (most recent call last):
      File "/var/task/lambda_function.py", line 46, in lambda_handler
      return response

    • @biswanathsah9732
      @biswanathsah9732 8 месяцев назад

      Thank you @asfandiyar5829.
      I wrote the whole code by watch but got Internal Server error . I couldn't recognised error . Thank you for the correct code , it worked for me 😊

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

    Very nice start-point walkthrough video. Thanks Felix! Way to go!

  • @tarcisiosteinmetz3472
    @tarcisiosteinmetz3472 2 года назад

    Great work, Felix Yu! You successfully explained API Gateway and Lambda in a very detailed way. Thank you.

    • @FelixYu
      @FelixYu  2 года назад

      Thank you 😄

  • @trevspires
    @trevspires 2 года назад +7

    Felix - any chance you can share the code repo??
    I'm a python noob, and getting intenral server errors when hitting API GW with a 502. Source could be helpful as I troubleshoot what I've done wrong.

  • @clivebird5729
    @clivebird5729 2 года назад

    Very helpful and insightful Felix. Thank you for sharing this, very much appreciated.

    • @FelixYu
      @FelixYu  2 года назад

      Glad that it’s helpful :)

  • @LS-qg2zn
    @LS-qg2zn Год назад

    Very very helpful tutorial for a beginner.. Thank you so much!

  • @JoseRodrigues-vd3si
    @JoseRodrigues-vd3si 2 года назад

    Thee best ever explanation I have saw about this subject.

    • @FelixYu
      @FelixYu  2 года назад

      Glad that u found it helpful :)

  • @anojamadusanka8914
    @anojamadusanka8914 2 года назад +6

    got error.
    {
    "message": "Internal server error"
    }
    502Bad Gateway. How to resolve this. No errors shown in the log events. Thank you.

    • @FelixYu
      @FelixYu  2 года назад +1

      did u print out the request event? how did it look like?

    • @fitnesswithvaibhav
      @fitnesswithvaibhav 2 года назад +2

      Got the same 502 bad gateway {
      "Message": "Interval server error"
      }

    • @fitnesswithvaibhav
      @fitnesswithvaibhav 2 года назад

      @@FelixYu please help me

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

      @@fitnesswithvaibhav got the same error

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

      I have checked and found it was my mistake

  • @SatyaNand592
    @SatyaNand592 2 года назад

    Awesome Video , very helpful and the standard of code is also adorable.
    one request Felix
    please create a separate playlist for python aws functionalities with the same standard of coding please that would be very helpful to the mass.

    • @FelixYu
      @FelixYu  2 года назад

      glad that its helpful 👍

  • @CMishra-kl4rb
    @CMishra-kl4rb Год назад +3

    Hi Felix, Can you please share the code because I'm getting error on my system as "Internal Server Error".
    Please share code anyone.

  • @kothon1
    @kothon1 2 года назад

    Bro you're a Lambda Beast!!! Alteast to a mere mortal novice!!!!

    • @FelixYu
      @FelixYu  2 года назад

      Thank you and glad that it’s helpful :)

  • @andynelson2340
    @andynelson2340 2 года назад

    Awesome, thanks for making this video😊

    • @FelixYu
      @FelixYu  2 года назад

      Glad that it’s helpful 👍

  • @stephensuico5741
    @stephensuico5741 2 года назад

    Thank you! Lot of value here

    • @FelixYu
      @FelixYu  2 года назад

      Glad that u found it helpful!!

  • @camichaves
    @camichaves 2 года назад

    Outstanding video! Thank you.

    • @FelixYu
      @FelixYu  2 года назад

      Glad that u found it helpful 👍

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

    Awesome video... could you please create a video for RDS instead of Dynamodb

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

    Hey Felix, you are doing a great job and thank you for this wonderful tutorial. I coded along with you in this tutorial but after trying to invoke my function via postman, I got a 500, internal server error, however, that is not my most significant concern. How are you able to put all these pieces of code together, how are you able to know where and when to use a particular function, module or class? I understand the basics of python but putting them together to form one big program like what you just did is a nightmare for me. How are you able to write almost 250+ lines of code forming a single program without mistakes? Is there a manual you guys use when coding? what is that cheat code you use bro?

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

      Were you able to resolve the internal server error? The health check works but then I get 502 error when I try the POST request.

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

      I fixed my internal server error! Turns out my DynamoDB table's partition key was misspelled. I had it as "productid" instead of "productId" (capital i was lowercase i). So for anyone getting a 502 I'd say go back and make sure all the small details are correct...

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

      @@andrzejwsol Thanks for the information
      I will look at my code again

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

      @@clintonebai1351 let me know how that goes. I’ve also read that Lambda is very particular and will throw a 502 if you have single quotation marks versus double (‘’ vs “”) so that’s worth checking out too

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

      @@andrzejwsol Alright, no worries but Can you share your code with me?

  • @victoradejumo566
    @victoradejumo566 2 года назад +2

    I tried updating using patch and I am getting Internal Server Error message. Wonderful video you put up. It was very helpful

    • @FelixYu
      @FelixYu  2 года назад +1

      that means there is an error in the lambda function. take a look at cloudwatch and see what the problem is

  • @christianechica4270
    @christianechica4270 2 года назад +2

    can you share the code via github?

  • @mukuljain8383
    @mukuljain8383 2 года назад

    Thanks for making videos for nodejs and lambda function super happy for that, also could you please make videos for js, your videos are great and i want to learn aws with nodejs and not python

    • @FelixYu
      @FelixYu  2 года назад

      The js video link is in the description!!

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

    This is a great video, super helpful! If I wanted to get all products with color "green", what would the scan body look like? Or would you not use scan for this functionality?

  • @surajthallapalli4227
    @surajthallapalli4227 2 года назад

    Loved it, thanks

    • @FelixYu
      @FelixYu  2 года назад

      Glad that it’s helpful :)

  • @lennyc2568
    @lennyc2568 2 года назад +2

    Hi getting [ERROR] KeyError: ‘httpMethod’ …. On post getting a 200 with the healthPath but the above error when trying to retrieve from an existing dynamodb

    • @FelixYu
      @FelixYu  2 года назад

      when u print out the request event, do u see httpMethod as one of the attributes??

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

    Thanks for this Felix, could you please create a tutorial to explain the CRUD operations in dybamoDB via Lambda. Querying in dynamoDB seems to a whole subject in itself.

  • @maheshbabuuda3059
    @maheshbabuuda3059 2 года назад +1

    Hi Felix Where can i get the lambda function code ??? python script ??

  • @DestroidAdicted
    @DestroidAdicted 7 месяцев назад

    I have a problem that when I make the query the event does not bring the httpMethod and path information, the event comes empty.

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

    Im getting 502 bad gateway in postman with 'internal server error' message, how should I solve this

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

      That means there’s an error in the lambda function. U can check the lambda log and see what the error is

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

      @@FelixYu can you please provide lambda code in description or somewhere

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

      downgrade node 18 to node 16

  • @bodyshapeandmotivation
    @bodyshapeandmotivation 2 года назад +1

    Can you share the code for the same

  • @yashmodi5761
    @yashmodi5761 2 года назад +1

    Please create tutorials using AWS cdk and boto3.

  • @amrithanshu3478
    @amrithanshu3478 9 месяцев назад

    {
    "message": "Internal server error"
    }
    how to resolve this

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

    Is it better to have CRUD in one api or C R U D in 4 diferents lambdas?

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

    Thank you for this video it's very useful , can you do same one with Redshift Database

  • @happylearning6543
    @happylearning6543 9 месяцев назад

    @Felix Yu, this video was really helpful thanks a lot!! I am stuck in integrating my lambda function, dynamodb and api gateway. Are you open to giving feedback on individual questions? Will be easier if I show you my approach and your coffee is on me for sure!

  • @user-et8et9hj3g
    @user-et8et9hj3g 9 месяцев назад

    Can you make the video for SpringBoot? It would be great help

  • @willianmaesato4618
    @willianmaesato4618 2 года назад

    Good night, first good work, I have a doubt I wanted to make a pagination in this model would it be possible for you to show how to do it? I tried to find something and try but I didn't succeed.

  • @user-pl8ou1nt9e
    @user-pl8ou1nt9e Год назад

    can u plz start classes of python from beginer to advanced level??

  • @tejashreepotdar9318
    @tejashreepotdar9318 2 года назад +1

    My update is failing
    I have written the same function as your's can you please share me the right code for Update

    • @FelixYu
      @FelixYu  2 года назад

      What error message are u getting?

  • @dahavlogs
    @dahavlogs 2 года назад +2

    Love your video. But i am getting an error. Even I followed everything. Can you please help me out. Error: {
    "errorMessage": "'httpMethod'",
    "errorType": "KeyError",
    "requestId": "7a3b8589-935a-41fe-bd22-5cfade4a3fa3",
    "stackTrace": [
    " File \"/var/task/lambda_function.py\", line 22, in lambda_handler
    httpMethod = event['httpMethod']
    "
    ]
    }

  • @rafaeldeghi587
    @rafaeldeghi587 11 месяцев назад

    Anyone had this error? Cant find a solution, its occurs when i try to use patch method, the value is updated, but the response from the api is 500
    [ERROR] UnboundLocalError: cannot access local variable 'response' where it is not associated with a value
    Traceback (most recent call last):
    File "/var/task/lambda_function.py", line 46, in lambda_handler
    return response

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

    It's work very well to me in POSTMAN and Requests in Python, but when I try make a request in my simple web page using Javascrip I'm having a issue call CORS "CORS policy: Request header field acess-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response", someone know what is?

  • @riazahmad5975
    @riazahmad5975 2 года назад

    Hello sir , please make vidoe that how to insert csv data to dynamodb in serverless framework using lambad in nodejs

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

    Thank you for the tutorial. Can you provide lambda code with gitlab link?

  • @Kukshalshrey
    @Kukshalshrey 2 года назад +1

    hey!! great video this really helped me clear few doubts!!
    but I am getting this error >>>
    "errorMessage": "'httpMethod'",
    "errorType": "KeyError",
    could you please help?

    • @FelixYu
      @FelixYu  2 года назад

      When u log out the whole even object in line 21, how does it look like? Does it show httpMethod as one of its attributes?

    • @Kukshalshrey
      @Kukshalshrey 2 года назад

      @@FelixYu if i print(event) iam getting
      {
      "key1":"value1",
      "key2":"value2",
      "key3":"value3"
      }

    • @FelixYu
      @FelixYu  2 года назад

      @@Kukshalshrey u needa configure ur lambda with api gateway and then use postman to hit the endpoint. U can’t just hit test in the lambda console

  • @virtualvessel0
    @virtualvessel0 7 месяцев назад

    Hi, thank you for this. Could you send or post the text source-code please. Thank.

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

    Where can we find the code?

  • @aryabasu814
    @aryabasu814 2 года назад

    thanks for this great video... where can I find the code? thanks

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

    will anybody please let me know how much will it cost for this above project in the vedio @Felix YU

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

    Please upload the code also so that we can test it

  • @ParthPatel-rh1ct
    @ParthPatel-rh1ct 2 года назад

    Having an issue when running the health check on Postman.
    {
    "errorMessage": "'httpMethod'",
    "errorType": "KeyError",
    "requestId": "f2c90a37-afe5-44f7-99a2-696dd8811efc",
    "stackTrace": [
    " File \"/var/task/lambda_function.py\", line 24, in lambda_handler
    httpMethod = event[\"httpMethod\"]
    "
    ]
    }
    Can you please post your code? Because, I don't know what happened with the code.

    • @gshan994
      @gshan994 2 года назад

      your event parameter doesnt have a key as "httpMethod". you can pass event[] as a parameter in json.dumps(response) instead of response

    • @FelixYu
      @FelixYu  2 года назад

      When u log out the whole event object in line 21, how does it look like? Does it show httpMethod as one of its attributes?

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

    whre i can get code of this project

  • @aaryanravi5265
    @aaryanravi5265 2 года назад

    ​ @Felix Yu Thanks a lot for this video, its really helpful.
    I am getting an error message as follows;
    "message": "Missing Authentication Token"
    any solution on this?

    • @FelixYu
      @FelixYu  2 года назад

      Did u accidentally enable authentication required in api gateway?

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

      Hi was your issue resolved?

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

    Great video. Thanks....pls I will appreciate if you can share this code. Something like the repo link

  • @gamerz5135
    @gamerz5135 8 месяцев назад

    did any one got the code? can u share it with me

  • @user-pl8ou1nt9e
    @user-pl8ou1nt9e Год назад

    can i get the code??

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

    Hi Felix, I see 502 bad gateway when call GET /product API. What could I check to solve this error? Thanks.

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

      That means there is an error in ur lambda function. Check the cloudwatch log in the lambda and see what the error is and then resolve it accordingly

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

      @@FelixYu Thanks a lot!

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

      downgrade node 18 to node 16

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

      downgrade node 18 to node 16

  • @tasmiyamuneer8886
    @tasmiyamuneer8886 2 года назад

    {
    "message": "Internal server error"
    }
    getting this error ..
    could u please solve it

    • @fitnesswithvaibhav
      @fitnesswithvaibhav 2 года назад

      Bro i am also getting same error i u get any solution please let me know

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

      @@fitnesswithvaibhav any luck?? i'm getting error at response = getProcessDomain(event['queryStringParameters']['process_domain']) line.

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

    Could you please put your code on git and share a link.

  • @chinmayakumarbiswal
    @chinmayakumarbiswal 2 года назад +1

    Sir can you share your code link

    • @FelixYu
      @FelixYu  2 года назад

      Idk if I saved the code when I did it. Let me check when I get a chance 👍

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

    can you please give the code?

  • @Nikhilsharma-tc5wr
    @Nikhilsharma-tc5wr Год назад

    Hi felix , your video in such a helpful can you share these code with me👍👍

  • @camelpilot
    @camelpilot 2 года назад

    Code repo please?

  • @hemantchaudhary3465
    @hemantchaudhary3465 2 года назад +1

    Hey!
    First of all thank you for a such a great video it really helped me alot:)
    So when i completed everything i was able to work with the post function after changing json.load to json.loads and the items did reflect i the table but the 'GET' funnctionality is not working.
    got this error on the postman with error code 502
    {
    "message": "Internal server error"
    }
    and then check the cloudwatch log and got the log as below.
    [ERROR] TypeError: 'NoneType' object is not subscriptable
    Traceback (most recent call last):
    File "/var/task/lambda_function.py", line 32, in lambda_handler
    response = getProduct(event['queryStringParameters']['productid'])
    Anyone encountered similar problem and was able to navigate through it?

  • @maheshbabuuda3059
    @maheshbabuuda3059 2 года назад

    where is the script

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

    This tutorial is okay for AWS free tier?

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

      Yes, it’s within the free tier limit if don’t run it a lot

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

      @@FelixYu Thanks

  • @hrishinani
    @hrishinani 2 года назад

    Hi I tried running the code but it shows this error :
    botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the PutItem operation: One or more parameter values were invalid: Missing the key product_id in the item,
    and thanks for the tutorial this one helped a lot

    • @FelixYu
      @FelixYu  2 года назад +1

      My guess is that ur table has a primary key set to be product_id but u passed in productId in the request?

    • @hrishinani
      @hrishinani 2 года назад

      @@FelixYu yes ! Thank you the problem is solved 🙏🏻

    • @FelixYu
      @FelixYu  2 года назад +1

      Glad that it’s working now 👍

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

    Can you share your code?

  • @tasmiyamuneer8886
    @tasmiyamuneer8886 2 года назад

    could you please post your code

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

    "message": "Internal server error"
    }

  • @saptanilchowdhury1851
    @saptanilchowdhury1851 2 года назад

    plz share the code

  • @jimmypeng5552
    @jimmypeng5552 2 года назад

    I got a error as below when doing the product get method.
    {
    "message": "Internal server error"
    }
    and then check the cloudwatch log and got the log as below.
    [ERROR] TypeError: 'NoneType' object is not subscriptable
    Traceback (most recent call last):
    File "/var/task/lambda_function.py", line 32, in lambda_handler
    response = getProduct(event['queryStringParameters']['productid'])
    thanks for your great class.

    • @jimmypeng5552
      @jimmypeng5552 2 года назад +1

      I resolved the issue. that's for the input value in Json format.
      such as the PATCH method to /product can solve the error "Internal server error". wish it can be helpful
      {
      "productid": "10001",
      "updateKey": "price",
      "updateValue": "1000"
      }

    • @FelixYu
      @FelixYu  2 года назад

      Glad that u got it to work 👍

    • @hemantchaudhary3465
      @hemantchaudhary3465 2 года назад

      Hey! I got the same error and i am not able to resolve it. How did you do it? Thanks:)

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

    Dislike, because you don't share the example code, what I supposed to do, copy it from the video?

  • @mayanksinha6591
    @mayanksinha6591 8 месяцев назад

    Used the same code and the same configuration but getting this error [ERROR] KeyError: 'httpMethod'
    Traceback (most recent call last):
    File "/var/task/code.py", line 23, in lambda_handler
    httpMethod = event['httpMethod']
    [ERROR] KeyError: 'httpMethod' Traceback (most recent call last): File "/var/task/code.py", line 23, in lambda_handler httpMethod = event['httpMethod']. Logging the event in cloudwatch I am getting this [INFO] 2024-01-12T11:22:01.150Z 12836e18-d826-4cad-8593-20e29a5f7b70 {'productid': '1101', 'color': 'red', 'price': '100'}

  • @saptanilchowdhury1851
    @saptanilchowdhury1851 2 года назад

    share the code please it is not working for me get, patch methods. POST and DELETE is working