Issues with API authentication, getting Pretix data etc

Hey guys,

I am having an issue with authorizing api keys. No matter how I enter it in the credentials area, I am getting 404 “Authorization is required!”

I am trying to get data from Pretix, an event ticketing software. So the goal on my end is to get Pretix customer data such as Name, Email, Address etc. Whenever I do not use API keys, it gives me post body such as this

{"notification_id": 199, "organizer": "ORGANIZERNAME", "event": "EVENTNAME", "code": "G0YUA", "action": "pretix.event.order.placed"}

From my understanding after checking the documentation here: Webhooks — pretix 2023.10.0.dev0 documentation

Pretix doesnt pass sensitive information over to webhooks with info such as Name, Email etc unless I am using API token. So my conclusion would be to use API token.

I’ve entered the API token as a Header Auth with the following information:

Name: Authentication
Value:

Tried in different ways:

Token API_TOKEN_HERE
Token $API_TOKEN_HERE
Bearer API_TOKEN_HERE
Bearer $API_TOKEN_HERE

None of these work. I tried as expression and as normal when it shows the **** to hide the information. Neither worked.

Any help would be appreciated

Hey @webmaster101,

according to the documentation of pretix, the header name is Authorization and not Authentication. By the way this applies to nearly every rest-based api.

The correct format is:

Authorization: Token e1l6gq2ye72thbwkacj7jbri7a7tvxe614ojv8ybureain92ocub46t5gab5966k

(The token is an example taken from their documentation)
https://docs.pretix.eu/en/latest/api/tokenauth.html#using-an-api-token

Cheers.

1 Like

Hi @nico-kow ,

Thanks for the update and support. I actually made an error by mentioning Authentication, it was actually Authorization and not what I mentioned. I was getting the same results mentioned. Do I copy and paste this

Token e1l6gq2ye72thbwkacj7jbri7a7tvxe614ojv8ybureain92ocub46t5gab5966k

I tried this both as expression and as fixed. When I enter it as fixed, it shows asterisks. Am I missing something?

Perhaps a silly question, but I want to rule out simple mistakes. Have you generated your own token as described in the instructions?

I don’t have an acoount at pretix, so I am not able to test it on my own.

Also some screenshots of the n8n node with the authentication would be very helpful.

Cheers.

1 Like

Hi @nico-kow

Thanks for the update and response! Yes, I generated the api here: Token-based authentication — pretix 2023.10.0.dev0 documentation

Here is the screenshot of the webhook setup

Here is the screenshot of the credentials configuration

Here is the error from pretix side

I’ve tried all 4 ways mentioned before in the
Token API_TOKEN_HERE
Token $API_TOKEN_HERE
Bearer API_TOKEN_HERE
Bearer $API_TOKEN_HERE

Not sure what to do next

Hi @nico-kow

Just did some testing for a few hours and I realize that none of the authorization commands work at all when using it in the webhook node. I tried all different kinds of settings and the only way I got it to work was to enter it in the HTTP Node instead as the saved configured credentials with the name “Authorization” and the value “Token API_TOKEN_HERE”

or manually entering it the “send headers” field with the following:

Name: Authorization
Value: Token API_TOKEN_HERE

Not sure if its a bug with the Webhook, but nothing works for me with api. I end up having to pull/requested it from the http node instead.

Another question/issue I have now is this. So I was able to figure out setting the Pretix API with a webhook and was able to get all customer information by using Token API for authentication. At the last step of a http request node, it sends the customer data to Acelle Mail software and adds them to the mailing list successfully.

I have a question in regards to getting consistent data. Everything is connecting great so far, and I am able to get the orders for an event with the following API End point

https://tickets.domain.com/api/v1/organizers/ORGANIZERNAME/orders/

What I am doing is getting the following customer data:

Node 1
• Name
• Address
• City
• State
• Zipcode

Node 2
• Ticket Type

The nodes combine and get all of the data mentioned from customers. My only issue now is every time I call this endpoint, ALL orders show up in the scheme/tables and it seems impractical as the data exports all orders instead of a recent one. Each order has has its own order ID, so if I enter no order ID, it will only copy specific data for a single customer order that I entered as JSON. I am trying to capture all of the data above every time that a new order comes in, to then automatically add each correct attendee information to the mailing list with the correct data of that customer.

For example, this is what is currently happening.

Order ID 1 is

John Doe
111 Address Avenue
New York
NY
11111

Order ID 2 is

Jane Doe
1245 Address Avenue
Chicago
IL
92938

If I enter the json variable {{ $json.results[1].positions[0].attendee_name }} - It will equal to John Doe. When it runs the webhook it will snatch this same exact customer (John Doe) each time and add them to the mailing list because im using the same json with the results being "“json.results[1]” in that json code, which signifies order ID1

Is there a specific endpoint, specific variables or a specific configuration required for me to do this correctly? Am I using the wrong approach? Here are screenshots

WORKFLOW

HTTP NODE WITH EXTRACTED DATA

Hi @webmaster101, from looking at your screenshot it appears you only have a single n8n item, with the actual results living inside the results field. So you probably want to use the Item Lists node here to split out your results field like so:

Afterwards, you can work with each result individually (as subsequent n8n nodes will run for each item they receive) using an expression like {{ $json.positions[0].attendee_name }}:

This might of course still need a bit of fine-tuning depending on your exact data structure but should hopefully give you an idea :slight_smile:

Hi @MutedJam

Thanks for the update and thorough response. I was able to get this to work even the way I set it up before, but I am going the route you mentioned as I trust your judgement. The only thing is how do I get each submission separate one by one that comes in?

For example

{{ $json.results[0].email }}

The zero would be the customer email for order 1. What would be the correct setup to consequently get the data and put all of the information together of the customer order to prepare to be subscribe to the mailing list software? I am just lost on the part of consequential data capturing.

Here is the process:

  • Customer buys ticket in pretix
  • n8n connects to pretix, gets the data and captures Email, name, address, city etc. of each order
  • n8n matches the data for the ALL json results labeled 23 for reach section such as Name, Address, city, state etc. Note: The json result “23” is the 23rd customer ticket order. Pretix identifies all fields with the same number
    Example
    {{ $json.results[23].name }}
    {{ $json.results[23].address }}
    {{ $json.results[23].city}}
  • Organize the data and sign up customer to the mailing software with api with all the information mentioned.

The issue is, i cant use {{ $json.results[*].email }} for it to capture each one. How would the system know to get them in order by result 23, result 24, result 25 and etc to sign them up to the mailing list software? Do I need to setup a variable configuration or a specific node to make consequential data exports?

Hey guys, any update on this?

I still cannot get the saved API credentials to work by saving it and using it in HTTP Request. Still gives me authentication wrong. The only way it works is if I manually enter it when I enabled “Specify headers” as

Authorization
value: Token APIHERE

Credential setup isn’t working. I am on the latest n8n.

Please advise, thanks.