Loadtesting SharePoint file uploads with mandatory fields in the content types

When a user uploads a document into a library it can be the case that mandatory fields need to be filled in. If these fields aren’t correctly submitted to the server then the file will remain checked out and other users will not be able to see it.

For an automated load test its important that it correctly supplies the required fields. In a previous post I described all the requests that are involved in the upload. In this post we’ll describe how to correctly POST the fields to the server.

Lets assume you have a required field called “ReferenceId” in your content type. When we want to POST the value of this field to SharePoint we must include SharePoint’s Field ID (a GUID) into the name of the form post parameter.

The first point where we need to intervene is the GET request to EditForm.aspx. Its response contains the ID of each field that’s included in the content-type. Each meta-data field of the content type is described in a JSON datastructure that looks like this:

//This JSON structure is sent as 1 very long line in the response
{
   "ListSchema":{
      "...":{
         "Id":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
         "...":"..."
      },
      "ReferenceId":{
         "Id":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
         "...":"..."
      },
      "...":"..."
   }
}

You can use the following ExtractionRule to extract the Id of your ReferenceId field:

Property Value
Context Parameter Name GUID_ReferenceId
Ends With
Extract Random Match False
Html Decode True
Ignore Case False
Index 0
Required True
Search in Headers False
Starts With “ReferenceId”:{“Id”:”
Use Regular Expression True

On the POST request to EditForm.aspx you need to add an extra Form Post Parameter like this:

Parameter Value Explanation
ClientFormPostBackValue_{{GUID_ReferenceId}}_ReferenceId Insert your desired value for the ReferenceId here See how the name of the form post parameter is constructed from the GUID we extracted earlier