-
-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments: Test the APIs #112
Comments
Can you give us example screen shots to test API with postman using AWS signature? thanks in advance |
@yashg5 I'm not too familiar with using Postman. Perhaps somebody else can give it a try. |
First off, thanks a ton for your tutorials. I went through the previous and now the revised. You're doing great work. For some reason I'm getting an error when testing the apis: Error: Invalid UserPoolId format.
I can't really think of a reason why I would be experiencing this problem. I've had no problems for any of the tests I've done so far that used the same user-pool-id. Any chance you could provide a sample apig-test call with actual values? |
@marshallbunch Here is a sample one that I was using. I altered some of the values around but the format should be like so. apig-test \
--username='[email protected]' \
--password='Passw0rd!' \
--user-pool-id='us-east-1_YBhdXYvix' \
--app-client-id='29qwoeorti0ctjkur5h91lkw5g' \
--cognito-region='us-east-1' \
--identity-pool-id='us-east-1:565cc505-5486-4278-bf0f-9736p9apq8m5' \
--invoke-url='https://w5z1hluqmp5.execute-api.us-east-1.amazonaws.com/test' \
--api-gateway-region='us-east-1' \
--path-template='/notes' \
--method='POST' \
--body='{"content":"hello world","attachment":"hello.jpg"}' |
No cigar. Won't make it past the user-pool-id. |
@marshallbunch Hmm can I see the complete output from the command? |
Sure: C:\Users\proet\AppData\Roaming\npm\node_modules\aws-api-gateway-cli-test\node_modules\amazon-cognito-identity-js\lib\CognitoUserPool.js:56
throw new Error('Invalid UserPoolId format.');
^
Error: Invalid UserPoolId format.
at new CognitoUserPool (C:\Users\proet\AppData\Roaming\npm\node_modules\aws-api-gateway-cli-test\node_modules\amazon-cognito-identity-js\lib\CognitoUserPool.js:56:13)
at authenticate (C:\Users\proet\AppData\Roaming\npm\node_modules\aws-api-gateway-cli-test\index.js:70:18)
at Object.<anonymous> (C:\Users\proet\AppData\Roaming\npm\node_modules\aws-api-gateway-cli-test\index.js:155:1)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7) |
For beginners it might be helpful to specify that YOUR_API_GATEWAY_URL should include the stage-name (prod in the example). "https://ly55wbovq4.execute-api.us-east-1.amazonaws.com/prod" |
did that as well. |
@marshallbunch Can you show me the full command you used as well? I'm not too familiar with the shell in Windows but let's take a look. @manubhat90 Good catch. It would work either way but that can be confusing. |
@jayair It is most definitely a syntax problem for the shell in windows. I got past the "invalid UserPoolId" error by getting rid of all the \ and the = and '. The current error is that it doens't like the json in the body content.
|
@marshallbunch Yeah I think we need to figure out how to format a string as an argument in the command line. And possibly escape the characters properly. |
Hey guys. Great walkthrough. Everything went smoothly until it was time to test the API. I'm getting 502 bad gateway back from API Gateway. I looked in the CloudWatch logs and found that it can't import modules.
I dug into this more by running the
This led me to look into the file being uploaded to S3 by Some of the results of
Any help would be very much appreciated. |
@tsdorsey Thanks for the details. As a quick sanity check, can I see your |
@jayair I should have done this before I posted. I have |
@tsdorsey Good catch. It appears I'm experiencing the same issue. |
@marshallbunch and @jayair I'm newish to webpack. Do you think you could point me in a direction so I could try to help figure this out? Got any gut feelings? |
Ok, so I watched the folders as I ran |
Getting 403 response Authenticating with User Pool
Getting temporary credentials
Making API request
{ status: 403,
statusText: 'Forbidden',
data: { message: 'Forbidden' } } |
Yeah I get the same response...
I guess we forgot some tweaks that are not in the code, but rather in the aws console. |
Ok, I got it working. http://serverless-stack.com/chapters/create-a-cognito-identity-pool.html Note that after doing so, I got these messes:
After that, I got correct 200 status. Hope it helps |
I'm not able to clear this test - if I put in all of my information in as a string, I get the cmd line response: Which makes no sense, because the user definitely exists - I created one with the same default credentials as in the example and a seperate one, which I used to create, update, delete the event.json file throughout the tutorial. When I remove all the semi-colons from the data, it runs through saying: And then gives me the same JSON token error as the other commenter upstairs! When I try just taking the string out the username and password, and keeping the rest of the strings there (and some variations) I get this error message: However, from looking at AWS documentation, Cognito Identity should be available in US-East-2... Halp! |
@tsdorsey I just tried your repo and I got it to deploy and call it fine. Of course the call failed because I don't have the IAM roles set up properly to do this. But It's calling everything fine. I suspect there is something going on on your local. Can you try the following and check the versions you are running? |
@marshallbunch Are you seeing the same error as @tsdorsey? If you go into your CloudWatch logs do you see the same error ( |
@Jonarod Yeah that error sounds like the IAM Role was not set properly. Thanks for reporting back with detail. I'm sure it'll help folks that run into something similar. |
@navinkumarr Your issue sounds like the issue @Jonarod ran into. You can check if the IAM Role has been set properly by going to your AWS Console > IAM > Roles (in the sidebar) > Cognito_notesidentitypoolAuth_Role > Scroll down and click on Show Policy. And make sure the policy looks like the one in the tutorial. |
@mikhaelbendavid Are you on Windows as well like @marshallbunch? Can I see the full command you used that generated that last error? |
@jayair I'm getting
Digging deeper into Cloudwatch, specifically the create lambda function, I get
My package.json is:
I haven't done any digging into the packaging that |
@thesavvygreek Can I see what version of Node, NPM, and Serverless you are using? |
@ahammond : the other thing that worked for me is setting credentials in the lambda like so
|
I also received a 403 - Forbidden access. After doublechecking erverything, it turns out, that the cut'n'paste of the Access Rule from the PDF was the problem. The hyphen characters from the longer lines are not copied and so the keywords are rubbish. You can try it by yourself. Just copy the snippet from the PDF and insert it into your editor. "Resource": [ must be and as well must be I'm not sure if it is a mac specific copy'n'paste issue, but it takes me hours to figure out whats going wrong. Maybe this hint is helpful .... |
@devsteff Hmmm that's weird. I just tried the exact same lines from the PDF and it worked okay for me. I'm on macOS 10.13. Are the hyphens missing only for these snippets? |
Yes, Seems so. I figured out, that when using the Apple Preview App for the PDF, copy'n'paste is ok. The hyphen is there, but line ist splittet and must be joined. But with Adobe Acrobat Reader App (Architecture: x86_64, Build: 18.11.20038.267465, AGM: 4.30.74, CoolType: 5.14.5, JP2K: 1.2.2.39492) |
@devsteff I see. Thanks for letting us know. I'll add a note in there. |
This issue was moved to https://discourse.serverless-stack.com/t/comments-test-the-apis/122 |
@Ashraf-Younis-NM Can you post this here - https://discourse.serverless-stack.com/t/comments-test-the-apis/122? We are moving any discussions around the chapters to Discourse. |
@jayair I'm running into the same problem as @mikhaelbendavid with error message. Checked all configurations all same as the tutorial. I was wondering what could be the problem? Many thanks! |
@KatieChen1001 I replied in the Discourse thread. |
I keep getting the 403 error but I'm not sure why. I've tried all the debugging suggestions, and even tried changing the policies around in the IAM (which arent giving me any denied errors). Here is what I'm finding in my logs
|
Something that I came across while testing in Windows is
NOTE. Most of the time the issue will be resolved by 1, 2, and 3 point. You only need to take care of mobilehub cognito identity pool id, if in your code you are using congintoIdentity from the event. As this will lead to some inconsistencies during testing, and you have to be more careful. So, I successfully tested my command as given below
|
Is this thread still being supported? I don't want to thoroughly describe my issue if no one is able to assist! Cheers. |
Post over on the forums instead — https://discourse.serverless-stack.com |
I am not sure if this thread is still maintained or not, but I just wanted to thank @bradodarb for his comment on solving 403 error. After following his advice I was able to solve error. And also, Thanks to @jayair for such an amazing tutorial. You really are helping every tech enthusiast in the best possible way. Cheers ! |
@mgonawala Thanks for kind words! Yeah we've moved over to our forums for chapter related comments. |
I'm really stuck here, been at it 3 days so far. Here is the forum post: https://discourse.serverless-stack.com/t/debugging-api-gateway/2011/3 - posting here in case anyone can help? |
I am on windows at stuck at this error, can anyone shed some light
|
Can you post this over on — https://discourse.serverless-stack.com/ |
Hello everyone I am having a problem with testing the api. When I run all the other tests in mock, my backend is updated and I see what I created,updated,deleted,etc. But when I run the command(I'm omitting alot of details. 'body' is my main question here): its giving me this error:
I'm not too sure what I'm doing wrong. I'm trying to fix the syntax error but I'm extremely stuck :( |
@awahmed, looks like you have a \ before "content" that doesn't belong there :) |
@jonasbarsten That's so wierd, I removed that \ and it gave me a very similar error at the same exact spot too. I just wanted to mention I am using powershell for this. Because I brought up Command Prompt and put my original command and that ended up working! |
@awahmed did you get to a solution for your error.? I am also getting same error and cannot go pass it. Your help would be highly appreciated. |
@agam-mishra I used Command prompt isntead of Powershell and ran the same command and it ended up working for me. For some reason Powershell was giving me that error only. Hope that helps |
Hi @awahmed I'm getting the same error now. Can u please help me in solving ? |
What tools do you use for testing, Postman or Apdiog |
Link to chapter - http://serverless-stack.com/chapters/test-the-apis.html
The text was updated successfully, but these errors were encountered: