Search code examples
restlinkedin-api

Linkedin Ads API What's the format of the `dateRange` request parameter?


What's the right format for dateRange for rest-li v2? The current examples in the documentation do not support it, and I don't understand from the rest-li documentation what's the format for it, exactly.

This is the request I make:

Headers:

  • X-Restli-Protocol-Version: 2.0.0
  • Authorization: Bearer <token-here>

URL (with request parameters):

https://api.linkedin.com/v2/adAnalyticsV2?q=analytics&pivot=CAMPAIGN&dateRange.start.day=1&dateRange.start.month=1&dateRange.start.year=2017&timeGranularity=DAILY

OR

URL - deconstructed (with request parameters):

  • Base URL:https://api.linkedin.com/v2
  • Params:

    • q:analytics
    • pivot:CAMPAIGN
    • dateRange.start.day:1
    • dateRange.start.month:1
    • dateRange.start.year:2017
    • timeGranularity:DAILY

Error I get:

{
   "serviceErrorCode": 100,
   "message": "Unpermitted fields present in PARAMETER: Data Processing >Exception while processing fields [/dateRange.start.day, /dateRange.start.month, >/dateRange.start.year]",
   "status": 403
}

Note: I'm referred to a question with the same error in the comments, however this might be caused by a different reason, and the answer there does not work for me. If by StackOverflow's standards you still think that it's a duplicate, please let me know and I'll close this question.


Solution

  • Solution provided by one of the LinkedIn developers:

    For Restli version 2, for parameter dateRange (tested only for endpoint AnalyticsV2):

    • rangeDate := (start[,end]) (end is optional)

    • start, end - type: Date

    • Date := (day, month, year)

      • day - type: integer (tested for single digit only)
      • month - type: integer (tested for single digit only)
      • year - type: integer (tested for 4 digits only)

    Final structure (not including the optional end): dateRange=(start:(day:,month:,year:))

    Example: dateRange=(start:1,month:1,year:2017)