python-omniture icon indicating copy to clipboard operation
python-omniture copied to clipboard

Use new Segments API

Open dancingcactus opened this issue 9 years ago • 6 comments

Update to add a segments property to the suite object

e.g. suite.segments

The property should use the Segments.Get API

dancingcactus avatar Mar 18 '15 15:03 dancingcactus

Hi there,

I'm receiving an error when calling suite.segments.

InvalidReportError: Bad Request: You do not have privileges to perform this operation. (None)

Here is the full traceback:

error {u'error_uri': None, u'error_description': u'You do not have privileges to perform this     operation.', u'error': u'Bad Request'}
---------------------------------------------------------------------------
InvalidReportError                        Traceback (most recent call last)
<ipython-input-16-187cc5da8349> in <module>()
----> 1 print suite.segments

c:\python27\lib\site-packages\omniture\utils.pyc in __call__(self, *args)
     14             return self.memoized[args]
     15         except KeyError:
---> 16             self.memoized[args] = self.function(*args)
     17             return self.memoized[args]
     18 

c:\python27\lib\site-packages\omniture\account.pyc in segments(self)
    129     def segments(self):
    130         """ Return the list of valid segments for the current report suite """
--> 131         data = self.request('Segments', 'Get')
    132         return Segment.list('segments', data, self, 'name', 'id')
    133 

c:\python27\lib\site-packages\omniture\account.pyc in request(self, api, method, query)
    104             raw_query['reportSuiteID'] = self.id
    105 
--> 106         return self.account.request(api, method, raw_query)
    107 
    108     def __init__(self, title, id, account):

c:\python27\lib\site-packages\omniture\account.pyc in request(self, api, method, query)
     52                 raise reports.ReportNotReadyError(json_response)
     53             elif json_response.get('error') != None:
---> 54                 raise reports.InvalidReportError(json_response)
     55             else:
     56                 return json_response

InvalidReportError: Bad Request: You do not have privileges to perform this operation. (None)

I'd love to use this Python wrapper for Omniture, but I need access to segments. I believe my report suite has over 5,000 segments, which may be causing problems. Any ideas? Thanks so much.

TrevorMcCormick avatar Sep 23 '15 21:09 TrevorMcCormick

I'm not sure if this Adobe Marketing post is useful but it says:

Many of the segments you create in the Marketing Suite UI will be tied to a specific report suite AND user. So, if you are not able to apply segments that you know exist or even see them when making the ReportSuite.GetSegments call, you should double check that you are working with the right report suite and that your API credentials are tied to the user you created the segment with.

TrevorMcCormick avatar Sep 23 '15 21:09 TrevorMcCormick

I'm also encountering the following error when either applying a filter using a segment or running suite.segments:

InvalidReportError: Bad Request: You do not have privileges to perform this operation. (None)

I'm able to log into the browser and apply the segment to the report, it does not appear to be a permissions issue.

Sweigalytics avatar Dec 04 '17 20:12 Sweigalytics

Same issue here when trying to access suit.segments, or report.filter. But found a work around for my needs:

I opened a pull request to my working patch at https://github.com/knanne/python-omniture/commit/92aecdf358ee96e27c33e6dd5c1b03534c48deee

This patch now returns suite.segments as an empty list, instead of completely failing.

Due to not being able to access segments, report.filter will not work because segments cannot be verified (i.e. id cannot be normalized), instead force the segment into your query using:

report = report.set("segments", [{"id" : "YOUR-SEGMENT-ID"}])

After running the report, during processing of data, this patch will produce the KeyError for unverified segment as a Warning instead, and continue to give you the data.

knanne avatar Feb 02 '18 11:02 knanne

I had the same issue when with a segment that was shared with me. Once I made a copy of the segment under my own user, I was able to use it in the API

aarontoledo avatar Feb 02 '18 15:02 aarontoledo

Can I get information With two segments at a time in one call? Example am.filter(segmentid,segmentid) Or am.filter(segmentid) am.filter(segmentid) This ways show me information with this segments(with and logical operation)?

manuelgomezrico avatar Jul 08 '18 08:07 manuelgomezrico