BadRequestException: 当授权类型为无或无效时,无法更新路由。
创始人
2024-11-20 08:00:31
0

可以通过以下代码示例解决“BadRequestException: 当授权类型为无或无效时,无法更新路由。”的问题:

import com.amazonaws.services.apigatewayv2.AmazonApiGatewayV2Client;
import com.amazonaws.services.apigatewayv2.model.*;

public class Main {
    public static void main(String[] args) {
        String apiId = "your-api-id";
        String routeId = "your-route-id";
        String authorizationType = "AWS_IAM"; // 要更新的授权类型

        AmazonApiGatewayV2Client apiGatewayClient = new AmazonApiGatewayV2Client();

        // 获取现有的路由信息
        GetRouteRequest getRouteRequest = new GetRouteRequest()
                .withApiId(apiId)
                .withRouteId(routeId);
        GetRouteResult getRouteResult = apiGatewayClient.getRoute(getRouteRequest);
        Route route = getRouteResult.getRoute();

        // 更新授权类型
        UpdateRouteRequest updateRouteRequest = new UpdateRouteRequest()
                .withApiId(apiId)
                .withRouteId(routeId)
                .withAuthorizationType(authorizationType)
                .withAuthorizerId(route.getAuthorizerId()) // 保持现有的授权器
                .withModelSelectionExpression(route.getModelSelectionExpression())
                .withOperationName(route.getOperationName())
                .withRequestModels(route.getRequestModels())
                .withRouteKey(route.getRouteKey())
                .withTarget(route.getTarget());
        UpdateRouteResult updateRouteResult = apiGatewayClient.updateRoute(updateRouteRequest);

        System.out.println("路由更新成功");
    }
}

请注意替换代码中的 your-api-idyour-route-id 为您的实际 API ID 和路由 ID。还要确保您的 AWS 认证凭证配置正确。这段代码将使用 AWS SDK for Java v1 来更新指定路由的授权类型为 AWS_IAM

相关内容

热门资讯

三分钟辅助!wepoker透视... 三分钟辅助!wepoker透视脚本免费使用视频,hh poker辅助有用吗,讲义教程(揭秘有挂)1、...
1分钟辅助!hhpoker软件... 1分钟辅助!hhpoker软件可以玩吗,hhpoker辅助软件下载,窍要教程(有挂神器)1、全新机制...
六分钟辅助!pokerworl... 六分钟辅助!pokerworld辅助器,hardrock作弊,法子教程(有挂教程)1、pokerwo...
9分钟辅助!wepoker辅助... 9分钟辅助!wepoker辅助是真的假的,wpk控制牌是真的吗,方式教程(揭秘有挂)1、完成wepo...
一分钟辅助!pokemmo脚本... 一分钟辅助!pokemmo脚本手机版,aapoker怎么提高中牌率,阶段教程(有挂解密)暗藏猫腻,小...
四分钟辅助!we-poker有... 四分钟辅助!we-poker有人玩吗,wepoker免费脚本咨询,演示教程(有挂教程)wepoker...
八分钟辅助!aa poker辅... 八分钟辅助!aa poker辅助,pokemmo内置修改器,方式教程(证实有挂)1、完成pokemm...
第2分钟辅助!智星菠萝透视,h... 第2分钟辅助!智星菠萝透视,hhpoker到底可以作弊码,策略教程(有挂规律)1、hhpoker到底...
第1分钟辅助!wepoker怎... 第1分钟辅助!wepoker怎么发冤家牌,pokemomo辅助软件,办法教程(有挂解惑)1、wepo...
第1分钟辅助!德普之星辅助工具... 第1分钟辅助!德普之星辅助工具如何打开,德州局hhpoker,总结教程(有挂辅助)1、进入游戏-大厅...