GAM soap API create Line Item

18 views
Skip to first unread message

D K

unread,
5:19 AM (17 hours ago) 5:19 AM
to Google Ad Manager API Forum
In the GAM background, create a Line Item. If the Line Item Type selects Ad Exchange (12), some required fields can be left unfilled, such as costPerUnit. But I use the api to create, and costPerUnit must be passed.

My request parameters: <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://www.google.com/apis/ads/publisher/v202508">
  <SOAP-ENV:Header>
    <ns1:RequestHeader>
      <ns1:networkCode>**</ns1:networkCode>
      <ns1:applicationName>**</ns1:applicationName>
    </ns1:RequestHeader>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <ns1:createLineItems>
      <ns1:lineItems>
        <ns1:orderId>***</ns1:orderId>
        <ns1:name>ApiTest-LineItem</ns1:name>
        <ns1:startDateTimeType>IMMEDIATELY</ns1:startDateTimeType>
        <ns1:unlimitedEndDateTime>1</ns1:unlimitedEndDateTime>
        <ns1:creativeRotationType>EVEN</ns1:creativeRotationType>
        <ns1:frequencyCaps>
          <ns1:maxImpressions>1</ns1:maxImpressions>
          <ns1:numTimeUnits>1</ns1:numTimeUnits>
          <ns1:timeUnit>MINUTE</ns1:timeUnit>
        </ns1:frequencyCaps>
        <ns1:lineItemType>AD_EXCHANGE</ns1:lineItemType>
        <ns1:environmentType>BROWSER</ns1:environmentType>
        <ns1:webPropertyCode>**</ns1:webPropertyCode>
        <ns1:targeting>
          <ns1:inventoryTargeting>
            <ns1:targetedAdUnits>
              <ns1:adUnitId>**</ns1:adUnitId>
              <ns1:includeDescendants>true</ns1:includeDescendants>
            </ns1:targetedAdUnits>
          </ns1:inventoryTargeting>
        </ns1:targeting>
      </ns1:lineItems>
    </ns1:createLineItems>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Failed: requestId: b141617bf1223cf60fbd589921945897, status: 500, faultcode: soap:Server, faultstring: [NotNullError.NULL @ costPerUnit]

Ad Manager API Forum Advisor

unread,
9:09 AM (13 hours ago) 9:09 AM
to qq861...@gmail.com, google-doubleclick...@googlegroups.com
Hi,

Thank you for contacting the Ad Manager API support team.

As per the API documentation, the attribute costPerUnit is required for creating a LineItem via Ad Manger API. I would suggest you to refer to this Java sample code to know all the required fields to create lineitem via Ad Manager API. You may check available client libraries for other languages. Let us know if you have any further queries.

Thanks,
 
Google Logo Ad Manager API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-09-04 13:09:38Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01u5oxh:ref" (ADR-00331858)



ouer1994

unread,
6:28 PM (4 hours ago) 6:28 PM
to Google Ad Manager API Forum
and I also want to know how to implement the GAM backend. When creating a Line Item, the value of Expected Creatives is All Request Sizes. How to implement it through the API

D K <qq861...@gmail.com> 于2025年9月4日周四 17:19写道:
--
You received this message because you are subscribed to the Google Groups "Google Ad Manager API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-doubleclick-for-p...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-doubleclick-for-publishers-api/34bb592f-624b-47f7-bdb7-378a5222429an%40googlegroups.com.


--
ouer1994
Reply all
Reply to author
Forward
0 new messages