Interface batch request method and device for filling data, equipment and medium

By automatically filling in interface request data, the problem of missing or incorrect filling in interface testing tools during batch requests is solved, an efficient interface testing process is achieved, and the workload of testers and enterprise costs are reduced.

CN120705035APending Publication Date: 2025-09-26ZIXUN TECHNOLOGY (FUJIAN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510734430.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-04
Publication Date
2025-09-26

AI Technical Summary

Technical Problem

When making batch requests, existing interface testing tools require manual filling of parameters for multiple interfaces, which can easily lead to omissions or errors, increasing the workload and time cost of testers.

Method used

Provides a method for batch interface requests to fill in data. By reading and parsing the interface request file uploaded by the user, it automatically fills in the missing parameters, builds the interface request data based on the basic information, and makes the interface request.

Benefits of technology

It greatly saves testers' time, reduces workload and enterprise costs, and improves test efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120705035A_ABST
    Figure CN120705035A_ABST
Patent Text Reader

Abstract

The invention provides an interface batch request method and device for filling data, equipment and a medium, and the method comprises the steps: setting a page for a user to fill in set basic information; reading an interface request file uploaded by a user, and analyzing the interface request file to obtain analyzed data; according to the format of the request data, obtaining corresponding data from the analysis data, and if all the data exist, constructing interface request data, and performing an interface request; if part of the basic information exists, corresponding data are obtained from the basic information, interface request data are constructed in combination with data in the analysis data, and an interface request is carried out; according to the method and the device, the time of testers is greatly saved, the working intensity of the testers is reduced, and the cost of enterprises is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of automated testing technology, and in particular to a method, device, equipment and medium for filling interface batch requests for data. Background Art

[0002] When using existing interface testing tools to test batch requests to an interface, the tester needs to fill in the URL, header, request method, request parameters, etc. used by each interface before testing. If the tester misses a parameter, the test will fail. When multiple interfaces of the same URL need to be tested at the same time, each parameter of each interface needs to be fully filled in before testing. This greatly increases the time required by the tester and requires the tester to concentrate to prevent missing or incorrect filling. Summary of the Invention

[0003] The technical problem to be solved by the present invention is to provide a method, device, equipment and medium for batch requesting an interface for filling data, which greatly saves the time of testers, reduces the workload of testers and reduces the cost of the enterprise.

[0004] In a first aspect, the present invention provides a method for filling data in batches of interface requests, comprising the following steps:

[0005] Step 1: Set up a page for users to fill in basic information;

[0006] Step 2: Read the interface request file uploaded by the user, parse it, and obtain the parsed data;

[0007] Step 3: According to the format of the request data, the corresponding data is obtained from the parsed data. If all the data exist, the interface request data is constructed and the interface request is made. If some of the data exist, the corresponding data is obtained from the basic information and combined with the data in the parsed data to construct the interface request data and make the interface request.

[0008] Step 4: Get the request result.

[0009] In a second aspect, the present invention provides an interface batch request device for filling data, comprising:

[0010] The basic information module sets up a page for users to fill in the basic information they set;

[0011] The upload parsing module reads the interface request file uploaded by the user, parses it, and obtains the parsed data;

[0012] Build a request module, obtain the corresponding data from the parsed data according to the format of the request data, if all the data exist, construct the interface request data and make the interface request; if some of the data exist, obtain the corresponding data from the basic information, and combine it with the data in the parsed data to construct the interface request data and make the interface request;

[0013] Get result module to get request results.

[0014] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect when executing the program.

[0015] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which implements the method described in the first aspect when the program is executed by a processor.

[0016] One or more technical solutions provided by the present invention have at least the following technical effects or advantages:

[0017] When the present invention performs batch request interfaces, testers do not need to fill in some data when filling in data. By triggering compatible logic, when performing batch interface concurrent requests, the missing parameters are automatically filled in, the interface request is completed, and the corresponding request result record is obtained, which greatly saves the tester's time, reduces the tester's workload, and reduces the company's costs.

[0018] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are specifically listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0020] Figure 1 This is a flowchart of the method in Example 1 of the present invention;

[0021] Figure 2 This is a schematic diagram of the structure of the device in Example 2 of the present invention. DETAILED DESCRIPTION

[0022] The embodiments of the present application provide a method, apparatus, device and medium for batch requesting an interface for filling data, thereby reducing the workload of testers and improving test efficiency and accuracy.

[0023] The technical solutions in the embodiments of this application have the following general ideas:

[0024] 1. Use the Excel template to write the interfaces you need to request (any number). When writing, you can miss any one or more of the URL, header, request method, request parameters, etc.

[0025] 2. Read the corresponding data by importing the Excel template. When no data can be read (information is missing), the compatibility logic will be triggered. By default, the corresponding missing data will be obtained from the interface of the requesting application. For example, if only the URL is written and nothing else is written, the matching data will be obtained from the URL matching application interface or the specified place to obtain the header, request method, and request parameters corresponding to the URL.

[0026] Specifically:

[0027] 1. Data in Excel file

[0028] The data in the Excel file is dynamic, and each row of data usually contains the following content (according to the code logic):

[0029] URL: The requested address.

[0030] Method: Request method (i.e. request type, such as GET, POST, etc.).

[0031] RequestBody: The content of the request body (usually form data or data in other formats).

[0032] These data are obtained in the code in the following ways:

[0033] javascript

[0034] const[urlValue,methodValue,requestBody]=row;

[0035] urlValue: The request address read from Excel.

[0036] methodValue: The request method read from Excel.

[0037] requestBody: The request body content read from Excel.

[0038] 2. Data in the page form

[0039] The data in the page form are fixed parameters entered by the user on the page. These parameters will be combined with the data in Excel to form the complete request parameters. The code obtains the form data in the following way:

[0040] javascript

[0041] const formData=newFormData(document.getElementById('apiform'));

[0042] The form may contain the following fields:

[0043] address: The default request address (if no URL is specified from Excel).

[0044] method: The default request method (if no method is specified from Excel).

[0045] request_data: The default request body content (if no request body is specified from Excel).

[0046] Other fields: may also include some additional request headers or other parameters.

[0047] 3. Combination of request parameters

[0048] Before sending the request, the code combines the data in Excel with the data in the form to form the final request parameters. The specific combination logic is as follows:

[0049] 3.1 Constructing new form data

[0050] javascript

[0051] constnewFormData=newFormData();

[0052] for(let[key,value]offormData.entries()){

[0053] if(key===='request_data'){

[0054] newFormData.append(key,requestBody); / / Use the request body in Excel

[0055] }else if(key==='address'&&urlValue){

[0056] newFormData.append(key,urlValue); / / Use the URL in Excel

[0057] }else if(key==='method'&&methodValue){

[0058] newFormData.append(key,methodValue); / / Use the method in Excel

[0059] }else{

[0060] newFormData.append(key,value); / / Use the default value in the form

[0061] }

[0062] }

[0063] If requestBody is specified in Excel, the value in Excel is used; otherwise, the default value in the form is used.

[0064] If urlValue is specified in Excel, the value in Excel is used; otherwise, the default value in the form is used.

[0065] If methodValue is specified in Excel, the value in Excel is used; otherwise, the default value in the form is used.

[0066] The other fields use the values ​​directly from the form.

[0067] 3.2 Setting Request Options

[0068] javascript

[0069] let fetchOptions = {

[0070] method:methodValue||formData.get('method'), / / Use the method in Excel or the default method in the form

[0071] headers:{

[0072] 'Accept':'application / json'

[0073] }

[0074] };

[0075] The request method (method) gives priority to the value in Excel, and if there is no value, it uses the default value in the form.

[0076] The Accept: application / json header is set in the request header, indicating that the response is expected to be in JSON format.

[0077] 3.3 Processing request body and query parameters

[0078] javascript

[0079] if(fetchOptions.method.toUpperCase()==='GET'){

[0080] newFormData.forEach((value,key)=>{

[0081] url.searchParams.append(key,value); / / Append form data as query parameters to the URL

[0082] });

[0083] }else{

[0084] fetchOptions.body = newFormData; / / Send form data as request body

[0085] }

[0086] If the request method is GET, the form data is appended to the URL as query parameters.

[0087] If it is another method (such as POST), the form data is sent as the request body.

[0088] 4. Summary: Parameters required by the request interface

[0089] According to the above logic, the request interface requires the following parameters:

[0090] Required parameters include:

[0091] URL: The requested address (obtained from Excel or the default value in the form).

[0092] Method: The requested method (obtained from Excel or the default value in the form).

[0093] RequestBody (optional): The content of the request body (obtained from Excel or the default value in the form).

[0094] Optional parameters include:

[0095] Other form fields: Depending on the form design, some additional request headers or other parameters may also be included.

[0096] Query parameters: If the request method is GET, the form data will be appended to the URL as query parameters.

[0097] 5. Examples

[0098] Assume that the Excel file contains the following content:

[0099] URL Method RequestBody https: / / example.com POST {"key":"value"}

[0100] Assume that you have the following fields in your form:

[0101] address: https: / / default.com

[0102] method: GET

[0103] request_data:{"default":"data"}

[0104] Then, the final request parameters are:

[0105] URL: https: / / example.com (from Excel)

[0106] Method: POST (from Excel)

[0107] RequestBody: {"key":"value"} (from Excel)

[0108] If a row of Excel data does not specify a URL or Method, the default value in the form will be used.

[0109] Example 1

[0110] like Figure 1 As shown, this embodiment provides a method for filling interface batch requests with data, including the following steps:

[0111] Step 1: Set up a page for users to fill in basic information;

[0112] Step 2: Read the interface request file uploaded by the user, parse it, and obtain the parsed data;

[0113] Step 3: According to the format of the request data, the corresponding data is obtained from the parsed data. If all the data exist, the interface request data is constructed and the interface request is made. If some of the data exist, the corresponding data is obtained from the basic information and combined with the data in the parsed data to construct the interface request data and make the interface request.

[0114] Step 4: Get the request result.

[0115] In this embodiment, preferably, the step 1 specifically includes: setting up a page for the user to fill in the set basic information, and converting the basic information into JSON format data, where the basic information includes: request address, request type and request body.

[0116] In this embodiment, preferably, step 3 is specifically as follows: according to the type of request, the format of the request data is set, and the corresponding data is obtained from the parsed data. If all data exist, the interface request data is constructed to make an interface request; if some data exist, the corresponding data is obtained from the basic information, and the interface request data is constructed in combination with the data in the parsed data to make an interface request.

[0117] In this embodiment, preferably, step 4 specifically includes: generating HTML content according to each request result:

[0118] If the request is successful, the requested URL, method, request parameters, status code, response time, and response content are displayed to check whether the response meets expectations;

[0119] If the request fails, an error message is displayed.

[0120] Based on the same inventive concept, this application also provides a device corresponding to the method in Example 1, see Example 2 for details.

[0121] Example 2

[0122] like Figure 2 As shown, in this embodiment, a device for batch requesting an interface for filling data is provided, including: a basic information module, which sets a page for users to fill in the set basic information;

[0123] The upload parsing module reads the interface request file uploaded by the user, parses it, and obtains the parsed data;

[0124] Build a request module, obtain the corresponding data from the parsed data according to the format of the request data, if all the data exist, construct the interface request data and make the interface request; if some of the data exist, obtain the corresponding data from the basic information, and combine it with the data in the parsed data to construct the interface request data and make the interface request;

[0125] Get result module to get request results.

[0126] In this embodiment, preferably, the basic information module specifically sets a page for users to fill in the set basic information, and converts the basic information into JSON format data. The basic information includes: request address, request type and request body.

[0127] In this embodiment, preferably, the request construction module specifically sets the format of the request data according to the type of request, obtains the corresponding data from the parsed data, and if all of the data exist, constructs the interface request data to make an interface request; if some of the data exist, obtains the corresponding data from the basic information, and constructs the interface request data in combination with the data in the parsed data to make an interface request.

[0128] In this embodiment, preferably, the result acquisition module specifically generates HTML content according to each request result:

[0129] If the request is successful, the requested URL, method, request parameters, status code, response time, and response content are displayed to check whether the response meets expectations;

[0130] If the request fails, an error message is displayed.

[0131] Since the device described in the second embodiment of the present invention is used to implement the method of the first embodiment of the present invention, those skilled in the art will be able to understand the specific structure and variations of the device based on the method described in the first embodiment of the present invention, and therefore will not be described in detail here. All devices used in the method of the first embodiment of the present invention fall within the scope of protection of the present invention.

[0132] Based on the same inventive concept, this application provides an electronic device embodiment corresponding to the first embodiment, see the third embodiment for details.

[0133] Example 3

[0134] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, any implementation method in the first embodiment can be implemented.

[0135] Since the electronic device described in this embodiment is the device used to implement the method in Example 1 of this application, based on the method described in Example 1 of this application, those skilled in the art will be able to understand the specific implementation of the electronic device of this embodiment and its various variations. Therefore, how the electronic device implements the method in the embodiment of this application will not be described in detail here. As long as the device used by those skilled in the art to implement the method in the embodiment of this application falls within the scope of protection to be provided by this application.

[0136] Based on the same inventive concept, this application provides a storage medium corresponding to Example 1, see Example 4 for details.

[0137] Example 4

[0138] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, any implementation method in the first embodiment can be implemented.

[0139] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CDROM, optical storage, etc.) containing computer-usable program code.

[0140] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0141] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0142] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0143] Although the specific embodiments of the present invention are described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and are not intended to limit the scope of the present invention. Equivalent modifications and changes made by those skilled in the art in accordance with the spirit of the present invention should be included within the scope of protection of the claims of the present invention.

Claims

1. A method for batch requesting an interface for filling data, characterized by: The steps include: Step 1: Set up a page for users to fill in basic information; Step 2: Read the interface request file uploaded by the user, parse it, and obtain the parsed data; Step 3: According to the format of the request data, the corresponding data is obtained from the parsed data. If all the data exist, the interface request data is constructed and the interface request is made. If some of the data exist, the corresponding data is obtained from the basic information and combined with the data in the parsed data to construct the interface request data and make the interface request. Step 4: Get the request result.

2. The method for batch requesting an interface for filling data according to claim 1, characterized in that: The step 1 specifically includes: setting up a page for the user to fill in the basic information set, and converting the basic information into JSON format data. The basic information includes: request address, request type and request body.

3. The method for batch requesting an interface for filling data according to claim 1, characterized in that: The specific steps of step 3 are: according to the type of request, set the format of the request data, obtain the corresponding data from the parsed data, if all exist, construct the interface request data and make an interface request; if some exist, obtain the corresponding data from the basic information, and construct the interface request data in combination with the data in the parsed data to make an interface request.

4. The method for batch requesting an interface for filling data according to claim 1, characterized in that: The step 4 is specifically as follows: generating HTML content according to each request result: If the request is successful, the requested URL, method, request parameters, status code, response time, and response content are displayed to check whether the response meets expectations; If the request fails, an error message is displayed.

5. An interface batch request device for filling data, characterized by: include: The basic information module sets up a page for users to fill in the basic information they set; The upload parsing module reads the interface request file uploaded by the user, parses it, and obtains the parsed data; Build a request module, obtain the corresponding data from the parsed data according to the format of the request data, if all the data exist, construct the interface request data and make the interface request; if some of the data exist, obtain the corresponding data from the basic information, and combine it with the data in the parsed data to construct the interface request data and make the interface request; Get result module to get request results.

6. The device for batch requesting interface for filling data according to claim 5, characterized in that: The basic information module specifically sets up a page for users to fill in the basic information they set, and converts the basic information into JSON format data. The basic information includes: request address, request type and request body.

7. The device for batch requesting interface for filling data according to claim 5, characterized in that: The specific steps of the request construction module are: according to the type of request, the format of the request data is set, and the corresponding data is obtained from the parsed data. If all the data exist, the interface request data is constructed to make an interface request; if some of the data exist, the corresponding data is obtained from the basic information, and the interface request data is constructed in combination with the data in the parsed data to make an interface request.

8. The device for batch requesting interface for filling data according to claim 5, characterized in that: The acquisition result module specifically generates HTML content according to each request result: If the request is successful, the requested URL, method, request parameters, status code, response time, and response content are displayed to check whether the response meets expectations; If the request fails, an error message is displayed.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method according to any one of claims 1 to 4 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.