从身体的Visual Basic中获取请求请求Restfulapi

发布于 2025-02-07 22:54:30 字数 1289 浏览 0 评论 0原文

因此,下面是我的RESTFUL API上的代码。它在Postman中工作完全很好。

我想用包含{“ email_address”的主体向API发送请求“> [email  prected] ”},但无法弄清楚如何在Visual Basic中做到这一点。任何帮助将不胜感激。

import boto3
import json

users = ["[email protected]", "[email protected]"]

def respond(res):
    return {
        'statusCode': 200,
        'body': json.dumps(res),
        'headers': {
            'Content-Type': 'application/json'
        }
    }

def lambda_handler(event, context):
    body = event['body'] 
    email_address = json.loads(body)['email_address']
    if email_address in users:
        response = "Authorised"
        return respond(response)
    else:
        response = "NotAuthorised"
        return respond(response)

它正在使用以下代码在Python中工作:

import requests
x = requests.request(method='get', url='APIURL', data='{"email_address":"[email protected]"}')
x.json()

猜猜我只需要一些帮助将其转换为Visual Basic即可。

SO, below is the code on my Restful API. It is working in Postman completely fine.

I am wanting to send a request to the API with the body containing {"email_address":"[email protected]"} but can't figure out how to do that in Visual Basic. Any help would be appreciated.

import boto3
import json

users = ["[email protected]", "[email protected]"]

def respond(res):
    return {
        'statusCode': 200,
        'body': json.dumps(res),
        'headers': {
            'Content-Type': 'application/json'
        }
    }

def lambda_handler(event, context):
    body = event['body'] 
    email_address = json.loads(body)['email_address']
    if email_address in users:
        response = "Authorised"
        return respond(response)
    else:
        response = "NotAuthorised"
        return respond(response)

It is working in Python with the below code:

import requests
x = requests.request(method='get', url='APIURL', data='{"email_address":"[email protected]"}')
x.json()

Guess I just need some help converting it to Visual Basic.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文