REST API create new baseline

Hi all,
I’m trying to create new baseline for monthly patching with REST API, but have errors. I would like to know where am I wrong.
I already went through all forum answers here but seems like something is missing.
I’m trying to use the Master Action Site (maybe I should use the patching support/BES Support/Patches for windows) but I guess maybe I’m using the non correct site type.
anyways…
this is my endpoint:
https://bigfixrootserver:52311/api/baselines/master/actionsite

Method: POST

My XML:

Output I get:
HTTP/1.1 404 Not Found
SessionToken: cnAwclhRdENLNTBnT1dTbGhzbGxaT1hNbnN0ZWxpMUQybkl0cUVFMmhRMHZwVXdNVVJMQW1TRStDdkszUC9FWjE3eXJHN0JHVUZ0T25oQ0M1MFJXSmc9PQ==
Set-Cookie: SessionToken=“rp0rXQtCK50gOWSlhsllZOXMnsteli1D2nItqEE2hQ0vpUwMURLAmSE+CvK3P/EZ17yrG7BGUFtOnhCC50RWJg==”;Path=/api;Secure;HttpOnly;Max-Age=300;Expires=Wed, 16 May 2018 08:43:33 +0000;
Strict-Transport-Security: max-age=31536000; includeSubDomains
Content-Type: text/plain; charset=UTF-8
Content-Length: 34

Requested resource does not exist.

Regards

Try just
/api/baselines/master

failed:

HTTP/1.1 500 Internal Server Error

SessionToken: TDNPN2d3Z3NKcko4ek9wRG44VHhqMURMRi9BeEZ3TkFXZUdDUHEySGVEQXpkWSs1cHJoRERUWDk1OEpiWEVBaGxTa0lrRnRPRk1kcjhzVGFRRnBKTEE9PQ==
Set-Cookie: SessionToken=“L3O7gwgsJrJ8zOpDn8Txj1DLF/AxFwNAWeGCPq2HeDAzdY+5prhDDTX958JbXEAhlSkIkFtOFMdr8sTaQFpJLA==”;Path=/api;Secure;HttpOnly;Max-Age=300;Expires=Thu, 24 May 2018 09:41:23 +0000;
Strict-Transport-Security: max-age=31536000; includeSubDomains
Content-Type: application/json
Content-Length: 173

{“format”:“Unexpected server error: {message}”,“arguments”:[“XML parsing error: no declaration found for element \u0027SourcedBaselineComponent\u0027 Line 9, Character 58”]}

What version of BigFix are you using?
Can you attache the XML you create?

In my environment that is running BigFix 9.5.8.38
I have the following in my BES XSD.

  <xs:element name="BaselineComponent" minOccurs="0" maxOccurs="unbounded">
                        <xs:complexType>
                          <xs:choice minOccurs="0">
                            <xs:sequence>
                              <xs:element name="Relevance" type="RelevanceString" />
                              <xs:element name="Delay" type="NonNegativeTimeInterval" minOccurs="0" />
                              <xs:sequence minOccurs="0">
                                <xs:element name="ActionScript" type="ActionScript" />
                                <xs:element name="SuccessCriteria" type="ActionSuccessCriteria" minOccurs="0" />
                              </xs:sequence>
                            </xs:sequence>
                            <xs:sequence>
                              <xs:element name="ActionScript" type="ActionScript" />
                              <xs:element name="SuccessCriteria" type="ActionSuccessCriteria" minOccurs="0" />
                              <xs:element name="Relevance" type="RelevanceString" />
                              <xs:element name="Delay" type="NonNegativeTimeInterval" minOccurs="0" />
                            </xs:sequence>
                          </xs:choice>
                          <xs:attribute name="Name" type="xs:normalizedString" />
                          <xs:attribute name="ActionName" type="xs:normalizedString" />
                          <xs:attribute name="IncludeInRelevance" type="xs:boolean" />
                          <xs:attribute name="SourceSiteURL" type="xs:anyURI" use="optional" />
                          <xs:attribute name="SourceID" type="xs:nonNegativeInteger" use="optional" />
                          <xs:attribute name="SyncStatus" type="xs:string" use="optional" />
                        </xs:complexType>

-jgo

1 Like

I’m with jgo on this, SourcedBaselineComponent doesn’t appear to be a valid tag in the schema.

Easiest thing is to create a simple baseline, then export it from the console so you have a good idea of what you need to create.

1 Like

You may want to start by exporting a baseline from the console and then attempting to import that first through the console for validation AND then through the API.

Also I recommend using postman as it is straight forward and allows you to share artifacts…

hi jgo,
I did created some simple baseline and exported it as XML and used it in my API client.
mission accomplished.

Thank a lot!!!

Cool Cool.

Did you use import? Could you share an example? Thank you for marking this answered.
-jgo

@borisre,can you please help to accomplish Base line creation and add component into it using rest api. If possible please share your XML file.

hi guys,
sorry for my late reply…
please see my XML file for creating baseline:

<?xml version="1.0" encoding="UTF-8"?>
<BES xsi:noNamespaceSchemaLocation="BES.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <Baseline>
                                <Title>Patching - BorisTest</Title> <!-- Set relevant name -->
                                <Description> <!-- Set relevant description -->
                                                My API test
                                </Description>
                                <Relevance>true</Relevance>
                                <Category/>
                                <Source>Internal</Source>
                                <SourceID/>
                                                <SourceReleaseDate>2018-05-28</SourceReleaseDate> <!-- Set relevant date -->
                                <SourceSeverity/>
                                <CVENames/>
                                <SANSID/>
                                <MIMEField>
                                                <Name>x-fixlet-modification-time</Name>
                                                <Value>Mon, 28 May 2018 08:30:00 +0000</Value> <!-- Set relevant date&time -->
                                </MIMEField>
                                <Domain>BESC</Domain>
                                <BaselineComponentCollection>
                                                <BaselineComponentGroup/>
                                </BaselineComponentCollection>
                </Baseline>
</BES>
1 Like

Thanks for your reply. Its working for me:slight_smile: