Current time: 12-06-2020, 01:01 AM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Defining custom hero via the API
05-02-2020, 08:59 AM
Post: #1
Defining custom hero via the API
I'm having trouble defining a custom hero via the API. I can get everything to work OK using the UI, but not the API. Here's my Python code:

# Prepare the post data
post_data = {'k': API_TOKEN,
'location': location,
'url': url,
'runs': 1,
'fvonly': 1,
#'debug': 1,
'keepua': 1,
'f': 'json',
'video': True,
'script': script,
'custom': '\n'.join(custom),
'heroElements': {"MWTEST":".product"}
}

# Make the request
response = requests.post(BASE_URL,
data=post_data,
timeout=10)

custom is a script - it runs OK and the output is in the results. heroElements works fine when I put the dict in the UI. But when I run this code, there's no custom hero at all in the results and nothing shows up in debug.

Has anyone got any advise on custom heroes via the API?
Find all posts by this user
Quote this message in a reply
05-13-2020, 11:55 PM
Post: #2
RE: Defining custom hero via the API
I figured out how to do this. The solution is to use json.dumps(), so the dict becomes:

'heroElements': json.dumps({"MWTEST":".product"})

I can confirm that this works - meaning you can define custom heroes through the API.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)