0

I need to generate data using the below url via requests.get :

fields = ("")
response_2 = requests.get(BASEURL + 'services/v17.0/report-jobs/' + jobId + "?fields=" +fields , 
headers = header_param)

For the purpose of the question, both the BASEURL and the JobID are pre defined. However, there are several field names in the dataset such as Date, [Agent Name], [Agent ID] etc. that I'm looking to generate. When I leave the fields object blank, no data is generated. When I try to define the fields object using

fields = ("Date, Agent Name")

or

fields = ("Date", "Agent Name")

I always get back the error : Invalid fields argument

What is the best way to fix this?

user10
  • 187
  • 2
  • 11
  • What do you want the result to be? – Mick Jan 11 '21 at 04:05
  • @Mick I am coercing the result to a json and then extracting a file url from there. – user10 Jan 11 '21 at 04:11
  • Since the fields object above is empty, the data I extract from the url ends up being empty – user10 Jan 11 '21 at 04:11
  • I mean how do you want the final url to look – Mick Jan 11 '21 at 04:11
  • HTTPS://API-C31.INCONTACT.COM/INCONTACTAPI/services/V20.0/files?fileName=CustomReports%5cApiReports%5cAgent+Login+Time+Details+Daily_20210110T203114.xls That;s the final url – user10 Jan 11 '21 at 04:22
  • That's kind of non-specific, I mean in relation to this url: "BASEURL+'services/v17.0/report-jobs/'+jobId+"?fields="+ fields". What does fields look like in this url? – Mick Jan 11 '21 at 04:26

1 Answers1

0

I'm not sure what result you want, but the problem is you're trying to concatenate a string and a tuple, and misusing a tuple.

requests.get(BASEURL + 'services/v17.0/report-jobs/' + jobId + "?fields=".join(str(i) for i in fields)
Mick
  • 796
  • 4
  • 8
  • I am seeing the error 404: Invalid or missing JobID. I defined the fields object as fiields = ("Date, Agent Name") and then executed the above get request – user10 Jan 11 '21 at 04:26