This message was deleted.
# community-help
s
This message was deleted.
k
I was thinking the problem might be caused by a wrong api key but that seems like it's not the problem.
I was able to connect to it via https://bfritscher.github.io/typesense-dashboard/ so it looks like this is not an api key issue.
also I now get errors when I search for the data from my application, looks like the api key can connect to Typesense and it is not the problem
d
can you give a full error? is it just a 403
if it were api key related the error would be `{"message": "Forbidden - a valid
x-typesense-api-key
header must be sent."}`
k
It's literally only the message "Forbidden"
I have code like this:
Copy code
_, err = typesenseClient.Collection("tasks").
		Documents().
		Import(typesenseTasks, &api.ImportDocumentsParams{
			Action:    pointer.String("upsert"),
			BatchSize: pointer.Int(100),
		})
and that seems to return the error (actually I'm only 90% sure this is the part that's throwing the error but I'm about to find out for sure)
d
if it's only happening when you're accessing it remotely you might check your webserver configuration
k
No, I run it via docker compose and am accessing it from the container
It seems to work fine when I access it remotely, just not when I access it via the cli
Looks like the Schema was created successfully, it's the indexing that fails... does not look like a connection problem
d
your example does not follow example given in the typesense-go repo
that pointer is not what they show
pointer.String("upsert")
does it work if you do one document at a time like they show here https://github.com/typesense/typesense-go#upserting-a-document
their Import call does not use a pointer.string to define the action
try using just
Action: "upsert"
instead
k
That does not work because the type is defined as
*string
(not
string
) in the params struct
I'll try one document at a time
d
i'm not sure you can do an upsert with an import
hm no you can
you might try writing the data to a jsonl and execute the upsert import request from the shell
Copy code
curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -X POST --data-binary @documents.jsonl \
'http://localhost:8108/collections/tasks/documents/import?action=upsert&batch_size=100'
k
jsonl is just one json document per line right?
d
ya, i found it easiest to write to a regular json and then use jq to convert to jsonl like their docs show
jq -c '.[]' documents.json > documents.jsonl
k
Doing this with curl works
d
i wonder if it's how you're defining the params inline
in their examples they define params separately and pass it to the import method
Copy code
params := &api.ImportDocumentsParams{Action: pointer.String("create")}
	responses, err := typesenseClient.Collection(collectionName).Documents().Import(documents, params)
k
it shouldn't really make a difference
d
_, err =
should that be
_, err :=
?
k
no,
err
is already defined in my case
:=
defines a new variable on the fly but it will give you a compile error when you try to redeclare an existing variable
d
the import function just builds a jsonl and calls importjsonl
i don't see anywhere that typesense would reply with 403 forbidden, unauthorized (bad api key) would reply with 401 unauthorized
i'm wondering if the error is occuring in the jsonDecoder logic
or encoder
k
That would surprise me
d
either it's an http 403 forbidden, or something in the encoding is giving a "forbidden" error
k
But I guess we'll find out once I deployed the Upsert per document
Upserting each document individually did add a few records but stopped after ~27
I start to suspect this is not an issue of Typesense
jup, the issue was in my application code 🤦‍♂️