title: AWS api gateway working in browser but returning 502 in fiddler
body: <p>I have a lambda function which would basically authenticate against the password stored in aws secret manager. The secret manager path would be the username and it will have the value for password. password will need to be passed in the header and username in the query. When I access the url <code>https://{myawsurl}.execute-api.{region}.amazonaws.com/demo/{username}</code> in a browser, I get the error <code>password is missing in the header</code>(which is expected). When I hit the url using fiddler I get 502 all the time.</p>
  <p>My api gateway is simply a GET to the lambda function below:</p>
  <pre><code>const aws = require(&quot;aws-sdk&quot;);
  
  const sm = new aws.SecretsManager({ region: 'us-east-1' })
  
  const getSecrets = async (SecretId) =&gt; {
      return await new Promise((resolve, reject) =&gt; {
          sm.getSecretValue({ SecretId }, (err, result) =&gt; {
              if (err) {
                  reject(err);
              }
              else {
                  resolve(JSON.parse(result.SecretString));
              }
          });
      });
  }
  
  const main = async (event) =&gt; {
      console.log(&quot;Event: &quot;, event);
      try {
          const username = event.queryStringParameters ? event.queryStringParameters.username : (event.pathParameters ? event.pathParameters.username : null);
          if (username === null || username === undefined || username.trim().length === 0) {
              if (username === null || username === undefined || username.trim().length === 0) {
                  return {
                      statusCode: 400,
                      headers: {
                          &quot;Content-Type&quot;: &quot;application/json&quot;
                      },
                      body: &quot;username is missing in the url. Please add `/?username={username}` or `/{username}` in the url&quot;
                  };
              }
          }
  
          const password = event.headers ? event.headers.password : null;
          if (password === null || password === undefined || password.trim().length === 0) {
              return {
                  statusCode: 400,
                  headers: {
                      &quot;Content-Type&quot;: &quot;application/json&quot;
                  },
                  body: &quot;password is missing in the header&quot;
              };
          }
  
          const secrets = await getSecrets(username);
          if (password !== secrets.password) {
              return {
                  statusCode: 403,
                  headers: {
                      &quot;Content-Type&quot;: &quot;application/json&quot;
                  },
                  body: &quot;Incorrect username/password&quot;
              };
          }
  
          return {
              statusCode: 200,
              headers: {
                  &quot;Content-Type&quot;: &quot;application/json&quot;
              },
              body: &quot;User is Authenticated&quot;
          };
      } catch (e) {
          return {
              statusCode: 404,
              headers: {
                  &quot;Content-Type&quot;: &quot;application/json&quot;
              },
              body: e.message
          };
      }
  }
  
  exports.handler = main;
  </code></pre>
  <p>My fiddler request is below:</p>
  <pre><code>GET https://{myawsurl}.execute-api.{region}.amazonaws.com/demo/{username} HTTP/1.1
  password: MyTestPassword
  
  </code></pre>
  <p>I saw other posts where they mentioned about having a statusCode and body being a string. I have those but still getting error...</p>
  <p>I added/removed the <code>headers: { &quot;Content-Type&quot;: &quot;application/json&quot;},</code> from the response and it made no difference..</p>
  <p><strong>EDIT:</strong> One another thing noticed is whenever I access the api gateway url via browser, it gets logged in my api's log group. But when it is accessed using fiddler it doesn't log. Not sure why...</p>
  <p><strong>EDIT:</strong> After the suggestion from @ArunK, I used Postman and I found it returns the expected response from the api gateway. I assume some settings in Fiddler may be causing this to happen..</p>