No HTTP resource was found that matches the request URI hen revoking grants

Viewed 32

I have written a function to revoke grants issued for a boundlock as shown in the code snipped below: For context, I first run a query to get all grants, and then use the ip UserID to get the specific grant that I want to revoke:

  async revokeGrant (user) {
const token = await this.getAuthorizationCodeToken(this.refreshToken)
try {
  const { data: allGrants } = await axios.get(
    `${this.baseUrl}/owners/${this.operatorAccountId}/grants`,
    {
      headers: {
        'Authorization': `Bearer ${token}`
      }
    }
  )
  const targetGrant = allGrants.find(grant => grant.contact.ipUserId === user.userId)
  // revoke grant after getting it from above
  const revokeResponse = await axios.post(
    `${this.baseUrl}/owners/${this.operatorAccountId}/grants/${targetGrant.id}/revoke`,
    {
      dryRun: true
    },
    {
      headers: {
        'Authorization': `Bearer ${token}`
      }
    }
  )
  console.log('revokeResponse:', revokeResponse)
} catch (error) {
  throw errors.customError(
    error.response.data,
    platform.responseCodes.InternalServer,
    'Device Error',
    false
  )
}

}

I however keep running into an error:

      Message: "No HTTP resource was found that matches the request URI 'https://tapkey-prod-main-rs.azurewebsites.net/api/v1/owners/*********/grants/*********/revoke'."
    }
  },
  isAxiosError: true,
  toJSON: [Function]
}
1 Answers

For revoking a grant the dryRun query parameter has to be added: https://tapkey-prod-main-rs.azurewebsites.net/api/v1/owners/*********/grants/*********/revoke?dryRun=false

For more details please have a look at https://developers.tapkey.io/openapi/tapkey_management_api_v1/#/Grants/Grants_RevokeById

Info: The dryRun parameter is required. If omitted, the request will fail.

Please don't use tapkey-prod-main-rs.azurewebsites.net as baseUri as this is not a public hostname and might removed or changed without any notice.

Related