简体   繁体   English

如何从我自己的应用程序向另一个 API 发送发布请求

[英]How can I send a post request to another API from my own application

urls.py网址.py

urlpatterns = [
    path('create_item/', CreateItem.as_view()),
]

serializers.py序列化程序.py

class ParentReferans(serializers.Serializer):
    name = serializers.CharField()
    value = serializers.IntegerField()
class ItemSerializer(serializers.Serializer):

    SubItem = serializers.BooleanField()
    Type = serializers.CharField()
    Name = serializers.CharField()
    ParentRef = ParentReferans(many=True, read_only=True)

views.py视图.py

class CreateItem(views.APIView):

    def post(self, request):

        response = requests.post('https://sandbox-quickbooks.api.intuit.com/v3/company/4620816365135062310/item?minorversion=4', data=request.data)

        serializer = ItemSerializer(data=request.data)
        if serializer.is_valid():
            return Response(serializer.data, status=status.HTTP_201_CREATED)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

I want to send post request to ( https://sandbox-quickbooks.api.intuit.com/v3/company/4620816365135062310/item?minorversion=4 ) address.我想将发布请求发送到 ( https://sandbox-quickbooks.api.intuit.com/v3/company/4620816365135062310/item?minorversion=4 ) 地址。 But I could not come to a conclusion about what I could do.但我无法得出我能做什么的结论。 How should I go about this problem?我该如何解决这个问题?

response = requests.post(url,params={"paramName": "paramValue"}) 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从我的 FastAPI 应用程序向另一个站点 (API) 发送 HTTP 请求? - How can I send an HTTP request from my FastAPI app to another site (API)? 如何从我的烧瓶应用程序向另一个站点发送GET请求? - How can I send a GET request from my flask app to another site? 无法将POST请求发送到我的基本FLASK Python应用程序 - Can't send POST request to my basic FLASK Python application 如何使用我自己的帐户通过电报 API 向某人发送消息 - How can I send a message to someone with telegram API using my own account 如何将数据从一个Django应用程序发送到另一个? - How can I send data from one Django application to another? 通过在post请求中发送文件名,我无法从我的应用程序中找到本地文件。 我如何找到该文件? - I can not find a local file from my application, by sending the filename in a post request. How do I find the file? 如何将(request.post)pandas 数据帧/json 发送到我的 raspberry-pi 网络服务器? - How can I send (request.post) pandas dataframe/json to my raspberry-pi webserver? 我无法使用 Barer 令牌将我的 POST 方法发送到 API - I can't send my POST method to the API with Barer Token 如何从 ReactJS Web 应用程序向 Django API 发送 POST 请求? - How to send POST request to Django API from ReactJS web app? 如何从 api 请求更新 VueJs 中的值,以便在不重新加载页面或单击操作的情况下更新我的按钮,还是有其他方法? - How can I update value in VueJs from api request so that my buttons will be updated without pagereloading or click action or is there another way?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM