Highlighted
Valued Contributor.
Valued Contributor.
694 views

Update test via rest API

Jump to solution

Hello, i am using hp pc 12.53.

I wanna update test via hp pc rest api. But get error:

HTTP/1.1 400 Bad Request

 

<Exception xmlns="http://www.hp.com/PC/REST/API">

  <ExceptionMessage>Invalid Request. Please verify that all mandatory fields defined and root element contain PC API namespace.</ExceptionMessage>

  <ErrorCode>1005</ErrorCode>

</Exception>

Can some one help and tell what is wrong in my update request.

 Here is my steps

1. I created test using rest api without error; 

Request URL is: 

/LoadTest/rest/domains/{domainName}/projects/{projectName}/tests/

POST method

Get response HTTP/1.1 201 Created with next xml body:

<Test xmlns="http://www.hp.com/PC/REST/API">

   <ID>2727</ID>

   <Name>testrestapi</Name>

   <CreatedBy>XXXXXXXX</CreatedBy>

   <LastModified>09/08/2017 13:19:02</LastModified>

   <TestFolderPath>Subject\Templates</TestFolderPath>

   <Content>

      <WorkloadType>

         <Type>basic</Type>

         <SubType>by test</SubType>

         <VusersDistributionMode>by number</VusersDistributionMode>

      </WorkloadType>

      <LGDistribution>

         <Type>all to each group</Type>

         <Amount>1</Amount>

      </LGDistribution>

      <MonitorProfiles/>

      <Groups>

         <Group>

            <Name>Script1</Name>

            <Vusers>10</Vusers>

            <Script>

               <ID>1695</ID>

            </Script>

            <Hosts/>

            <RTS>

               <Pacing>

                  <NumberOfIterations>1</NumberOfIterations>

                  <StartNewIteration Type="immediately"/>

               </Pacing>

               <ThinkTime Type="replay"/>

               <Log Type="disable"/>

            </RTS>

         </Group>

         <Group>

            <Name>Script2</Name>

            <Vusers>10</Vusers>

            <Script>

               <ID>1669</ID>

            </Script>

            <Hosts/>

            <RTS>

               <Pacing>

                  <NumberOfIterations>1</NumberOfIterations>

                  <StartNewIteration Type="immediately"/>

               </Pacing>

               <ThinkTime Type="replay"/>

               <Log Type="disable"/>

            </RTS>

         </Group>

      </Groups>

      <Scheduler>

         <Actions>

            <Action>

               <Initialize Type="just before vuser runs"/>

            </Action>

            <Action>

               <StartVusers Type="simultaneously"/>

            </Action>

            <Action>

               <Duration Type="run for">

                  <TimeInterval>

                     <Minutes>5</Minutes>

                  </TimeInterval>

               </Duration>

            </Action>

            <Action>

               <StopVusers Type="simultaneously"/>

            </Action>

         </Actions>

      </Scheduler>

   </Content>

</Test>

2. Now i want to update something in my test. But get error described above.

request URL is: 

/LoadTest/rest/domains/{domainName}/projects/{projectName}/tests/2727

Content-type: application/xml

Here is my request body:

<Test xmlns="http://www.hp.com/PC/REST/API">

 

 

   <Content>

      <WorkloadType>

         <Type>basic</Type>

         <SubType>by test</SubType>

         <VusersDistributionMode>by number</VusersDistributionMode>

      </WorkloadType>

      <LGDistribution>

         <Type>all to each group</Type>

         <Amount>1</Amount>

      </LGDistribution>

      <MonitorProfiles/>

      <Groups>

         <Group>

            <Name>Script1</Name>

            <Vusers>100</Vusers>   //here i changed vusers number

            <Script>

               <ID>1695</ID>

            </Script>

            <Hosts/>

            <RTS>

               <Pacing>

                  <NumberOfIterations>1</NumberOfIterations>

                  <StartNewIteration Type="immediately"/>

               </Pacing>

               <ThinkTime Type="replay"/>

               <Log Type="disable"/>

            </RTS>

         </Group>

         <Group>

            <Name>Script2</Name>

            <Vusers>10</Vusers>

            <Script>

               <ID>1669</ID>

            </Script>

            <Hosts/>

            <RTS>

               <Pacing>

                  <NumberOfIterations>1</NumberOfIterations>

                  <StartNewIteration Type="immediately"/>

               </Pacing>

               <ThinkTime Type="replay"/>

               <Log Type="disable"/>

            </RTS>

         </Group>

      </Groups>

      <Scheduler>

         <Actions>

            <Action>

               <Initialize Type="just before vuser runs"/>

            </Action>

            <Action>

               <StartVusers Type="simultaneously"/>

            </Action>

            <Action>

               <Duration Type="run for">

                  <TimeInterval>

                     <Minutes>5</Minutes>

                  </TimeInterval>

               </Duration>

            </Action>

            <Action>

               <StopVusers Type="simultaneously"/>

            </Action>

         </Actions>

      </Scheduler>

   </Content>

</Test>

0 Likes
1 Solution

Accepted Solutions
Highlighted
Valued Contributor.
Valued Contributor.

Re: Update test via rest API

Jump to solution

Solved. Removed test element.  

Request is:

 

   <Content xmlns="http://www.hp.com/PC/REST/API">

      <WorkloadType>

         <Type>basic</Type>

         <SubType>by test</SubType>

         <VusersDistributionMode>by number</VusersDistributionMode>

      </WorkloadType>

      <LGDistribution>

         <Type>all to each group</Type>

         <Amount>1</Amount>

      </LGDistribution>

      <MonitorProfiles/>

      <Groups>

         <Group>

            <Name>Script1</Name>

            <Vusers>100</Vusers>   //here i changed vusers number

            <Script>

               <ID>1695</ID>

            </Script>

            <Hosts/>

            <RTS>

               <Pacing>

                  <NumberOfIterations>1</NumberOfIterations>

                  <StartNewIteration Type="immediately"/>

               </Pacing>

               <ThinkTime Type="replay"/>

               <Log Type="disable"/>

            </RTS>

         </Group>

         <Group>

            <Name>Script2</Name>

            <Vusers>10</Vusers>

            <Script>

               <ID>1669</ID>

            </Script>

            <Hosts/>

            <RTS>

               <Pacing>

                  <NumberOfIterations>1</NumberOfIterations>

                  <StartNewIteration Type="immediately"/>

               </Pacing>

               <ThinkTime Type="replay"/>

               <Log Type="disable"/>

            </RTS>

         </Group>

      </Groups>

      <Scheduler>

         <Actions>

            <Action>

               <Initialize Type="just before vuser runs"/>

            </Action>

            <Action>

               <StartVusers Type="simultaneously"/>

            </Action>

            <Action>

               <Duration Type="run for">

                  <TimeInterval>

                     <Minutes>5</Minutes>

                  </TimeInterval>

               </Duration>

            </Action>

            <Action>

               <StopVusers Type="simultaneously"/>

            </Action>

         </Actions>

      </Scheduler>

   </Content>

View solution in original post

0 Likes
3 Replies
Highlighted
Valued Contributor.
Valued Contributor.

Re: Update test via rest API

Jump to solution

Solved. Removed test element.  

Request is:

 

   <Content xmlns="http://www.hp.com/PC/REST/API">

      <WorkloadType>

         <Type>basic</Type>

         <SubType>by test</SubType>

         <VusersDistributionMode>by number</VusersDistributionMode>

      </WorkloadType>

      <LGDistribution>

         <Type>all to each group</Type>

         <Amount>1</Amount>

      </LGDistribution>

      <MonitorProfiles/>

      <Groups>

         <Group>

            <Name>Script1</Name>

            <Vusers>100</Vusers>   //here i changed vusers number

            <Script>

               <ID>1695</ID>

            </Script>

            <Hosts/>

            <RTS>

               <Pacing>

                  <NumberOfIterations>1</NumberOfIterations>

                  <StartNewIteration Type="immediately"/>

               </Pacing>

               <ThinkTime Type="replay"/>

               <Log Type="disable"/>

            </RTS>

         </Group>

         <Group>

            <Name>Script2</Name>

            <Vusers>10</Vusers>

            <Script>

               <ID>1669</ID>

            </Script>

            <Hosts/>

            <RTS>

               <Pacing>

                  <NumberOfIterations>1</NumberOfIterations>

                  <StartNewIteration Type="immediately"/>

               </Pacing>

               <ThinkTime Type="replay"/>

               <Log Type="disable"/>

            </RTS>

         </Group>

      </Groups>

      <Scheduler>

         <Actions>

            <Action>

               <Initialize Type="just before vuser runs"/>

            </Action>

            <Action>

               <StartVusers Type="simultaneously"/>

            </Action>

            <Action>

               <Duration Type="run for">

                  <TimeInterval>

                     <Minutes>5</Minutes>

                  </TimeInterval>

               </Duration>

            </Action>

            <Action>

               <StopVusers Type="simultaneously"/>

            </Action>

         </Actions>

      </Scheduler>

   </Content>

View solution in original post

0 Likes
Highlighted
New Member.

Re: Update test via rest API

Jump to solution

Hi Team,

We are also facing the same issue,

Steps followed,
1. Invoked GET method and generated XML from an existing test,
2.Updated XML,
3.Invoked POST and supplied updated XML.
 
getting below error message.
 
Invalid design performance test request.Ensure that tag name is 'Test' and the request must contain a PC API namespace. Verify that all mandatory fields (as define in the PC API documentation) are defined.
ErrorCode - 1651

 

0 Likes
Highlighted
New Member.

Re: Update test via rest API

Jump to solution

If the Test element is removed, where we can provide the Test name and Folder path.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.