This article is an original article, please indicate the source of the original article when reprinting it
The blog address of this article:https://hpzwl.blog.csdn.net /article/details/134305752
The complete collection of blog posts by Red Fatty (Red Imitation): Development technology collection (including Qt practical technology, Raspberry Pi, 3D, OpenCV, OpenGL, ffmpeg, OSG, microcontroller, software and hardware combination, etc.) is being continuously updated... (click the portal)
Others (programming related)
need
When developing Qt, you need to use HTTP post requests, but you need to simulate LAN testing by yourself, because our development is mainly for embedded and desktop software development, and we are not professional in the knowledge and tools of the web. I looked for some tools and found that I need to install Java. The environment required me to log in and register an account, but I couldn't, so I searched around and found a domestic software that can be used as an HTTP test for the local area network. I cooperated with Postman to test the post again, and achieved the goal immediately without logging in.
Fool-like usage process (software ApiPost, third-party testing: get requests can use the browser, post simulation requests require postMan software)
Step 1: Download the software and install it
Search for apipost software and install it:
Step 2: Open apiPost software
Step 3: Establish an http server to simulate the get interface
Establish the http interface directly here (because the input URL on the web page is get, not post)
Click to copy, and the copied URL is:
This is because the direct use of the web page URL is a get request, our interface is post, and the web page input is a get request** (refer to " Enter the pit 1")**, change the following to get and then test:
At this point, the test get interface can be implemented.
You can design some success returns, error returns, and judgment conditions. We won’t go into details here. You can manually modify and save them for each test.
Step 4: Test the post interface
Copy the above and change it to post:
Use the postMan tool for testing below (use the post method in the code):
Fall into the trap
Pitfall 1: After establishing the post interface, the web page input always gets 404
question
After establishing the post interface, the browser tests the URL and returns 404.
reason
The post interface requires submission, and the actual input is a get request directly in the browser.
solve
Just use postMan to simulate post requests.
This article is an original article, please indicate the source of the original article when reprinting it
The blog address of this article:https://hpzwl.blog.csdn.net /article/details/134305752