-1
    @task
    def constraintsuploaddoc(self, false=None):

        headersc = {'content-type': 'multipart/form-data; '
                                    'boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW',
                    'Accept-Encoding': 'gzip, deflate, br',
                    'Content-Length': '433', 'Accept': '*/*'}
        payload = {
            'blobText': '{ ID: 3, FileClass: "LogicsticsConstraints", FileDescriptor: "test", FieldName: '
                        '"lookup.csv" }'}
        files = [
            ('File',
             ('lookup.csv', open(r"C:\Perffiles\lookup.csv",'rb'), 'text/csv'))
             ]
        rupload = self.client.put("/api/v1/FileUpload/Upload", data=payload,
                                  files=files,
                                  verify=False,
                                  headers=headersc, name="constraintsuploaddoc")

        if rupload.status_code == 200:
            # we got a 200 OK
            rupload.success()
        else:
            print(rupload)
            rupload.failure("Error occured")

postman request

Error:

    "title": "One or more validation errors occurred.",
    "status": 400,
    "traceId": "00-415d71c9881187498929206abd2ec4ab-9f31d5c108f99944-00",
    "errors":{
        "": ["Failed to read the request form. Unexpected end of Stream, the
 content may have already been read by another component. "]
    }
}
DV82XL
  • 5,350
  • 5
  • 30
  • 59
  • Start with using the Python Requests module to get something working. You should then be able to almost drop in replacement with the Locust client. – Solowalker Feb 27 '21 at 15:07

2 Answers2

0
import requests
from requests_toolbelt.multipart.encoder import MultipartEncoder
import json

multipart_data = MultipartEncoder(
fields={
    # a file upload field
    'file': ('lookup.csv', open(r'C:\Perffiles\lookup.csv', 'rb'), 'text/plain'),
    # plain text fields
    'blobText': '{ ID: 3, FileClass: "LogicsticsConstraints", FileDescriptor: "test", 
      FieldName: "aep_lookup -test1.csv" }'
    }
    )

  urlupload = "https://1.2.3.4/api/v1/FileUpload/Upload"
 headersc = {'content-type': multipart_data.content_type,
        'Host': '1.2.3.4', 'Accept': '*/*'}
response = requests.request("PUT", urlupload, headers=headersc, data=multipart_data, verify=False)
0

Maybe you are hitting this issue with FastHTTPUser

https://github.com/locustio/locust/issues/1640

aekis.dev
  • 2,626
  • 1
  • 12
  • 19