Closed hekler91 closed 2 years ago
What are the sequence of function calls you're doing in your PHP? Can you post your code block? It looks like the credentials are invalid, but I wouldn't expect it to work on your second call.
Thanks for reporting.
This is the connection in the .env file:
FM_DB_HOST = filemaker01.server
FM_DB_USERNAME = apirest
FM_DB_PASSWORD = vkjfkdjskfs
this is the database connection in database.php
'DATABASENAME' => [
'driver' => 'filemaker',
'host' => env ('FM_DB_HOST', ''),
'database' => 'DATABASENAME',
'username' => env ('FM_DB_USERNAME', ''),
'password' => env ('FM_DB_PASSWORD', ''),
'prefix' => env ('FM_DB_PREFIX', ''),
'version' => env ('FM_DB_VERSION', 'vLatest'),
'protocol' => env ('FM_DB_PROTOCOL', 'https'),
],
DATABASENAME class
<? php
namespace App \ Models \ FileMaker \ DATABASENAME;
use App \ Traits \ FormatsAttributeNames;
use BlueFeather \ EloquentFileMaker \ Database \ Eloquent \ FMModel;
use Illuminate \ Database \ Eloquent \ Factories \ HasFactory;
class DATABASENAME extends FMModel
{
use HasFactory;
use FormatsAttributeNames;
protected $ connection = 'DATABASENAME';
protected $ layout = 'ApiLayout';
protected $ fieldMapping = [
'Article (1)' => 'Article',
'Article2' => 'Article2',
'BestellNr2' => 'Bestellnr_2',
];
}
and I have now created a command that synchronizes data from FileMaker to Mysql DB
protected $ signature = 'sync-filemaker-db {db}';
public function handle ()
{
switch ($ this-> argument ('db')) {
case 'DATABASENAME':
$ this-> handleDATABASE ();
break;
default:
$ this-> error ('No valid database provided');
return 1;
}
return 0;
}
public static function> handleDATABASE ()
{
$ offset = 0;
$ count = DATABASENAME :: count ();
while ($ offset <$ count) {
DATABASENAME :: offset ($ offset) -> get () -> each (function (DATABASENAME $ item) use (& $ offset) {
$ recordId = (int) $ item-> getRecordId ();
MYSQLTABLENAME :: updateOrCreate ([
'record_id' => $ recordId,
], DATABASENAME :: formatAttributeNames ($ item-> getAttributes ()));
$ offset ++;
});
}
dump ($ offset);
}
and then I call my command:
php artisan sync-filemaker-db DATABASENAME
and then every time I first call the command php artisan sync-filemaker-db DATABASENAME this error pops up:
BlueFeather\EloquentFileMaker\Exceptions\FileMakerDataApiException
Authorization header 'Basic' invalid.
at C:\xampp\htdocs\enterprise-service-bus\vendor\bluefeather\eloquent-filemaker\src\Services\FileMakerConnection.php:167
163▕ // API token is expired. We should expire it in the cache so it isn't used again.
164▕ $this->forgetSessionToken();
165▕ return;
166▕ default:
"https://filemaker01.server/fmi/data/vLatest/databases/DATABASENAME/layouts/ApiLayout/records/", [])
And the second time I call her again, and so every next time she does everything.
Does the library take the Token and then use it, but the old one stays with her, I don't know what else could be the problem?
Are you using FileMaker Cloud or regular self-hosted FMS?
Ah, never mind. That wouldn't be the issue here.
Yes, I’ve seen you issue and haven’t had time to set up a new app and test environment to attempt to reproduce this yet. It’s on my list to look at.
-- David Nahodyl @.*** https://bluefeathergroup.com (770) 765-6258
On June 29, 2022 at 3:19:06 PM, hekler91 @.***) wrote:
can you please help me with my problem with FileMaker?
https://github.com/BlueFeatherGroup/eloquent-filemaker/issues/21 [ https://opengraph.githubassets.com/458d315148251df5335a303218065025bad385ebe0001b62817c1be21b7c39da/BlueFeatherGroup/eloquent-filemaker/issues/21 ]https://github.com/BlueFeatherGroup/eloquent-filemaker/issues/21 Authorization header 'Basic' invalid. · Issue #21 · BlueFeatherGroup/eloquent-filemaker< https://github.com/BlueFeatherGroup/eloquent-filemaker/issues/21> Please if you can help me why I always get this error the first time I call a function, the second time I run it then it works. FileMaker Version: 18 Php Version : 7.4 This is a mistake: {"mes... github.com
Von: Smef @.> Gesendet: Dienstag, 28. Juni 2022 19:57 An: BlueFeatherGroup/eloquent-filemaker @.> Cc: hekler91 @.>; Manual @.> Betreff: Re: [BlueFeatherGroup/eloquent-filemaker] Authorization header 'Basic' invalid. (Issue #21)
What are the sequence of function calls you're doing in your PHP? Can you post your code block? It looks like the credentials are invalid, but I wouldn't expect it to work on your second call.
— Reply to this email directly, view it on GitHub< https://github.com/BlueFeatherGroup/eloquent-filemaker/issues/21#issuecomment-1169047236>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/AKFJTDGEG56K2PKOOROREJ3VRM4KFANCNFSM52BEN6CA
. You are receiving this because you are subscribed to this thread.Message ID: @.***>
— Reply to this email directly, view it on GitHub https://github.com/BlueFeatherGroup/eloquent-filemaker/issues/21#issuecomment-1170393825, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCA6RSDUZ6PTNGHLCZ4ER3VRSOSTANCNFSM52BEN6CA . You are receiving this because you commented.Message ID: @.***>
Thanks for your response. We don't use the Cloud, FileMaker is installed on our internal server.
Okay, please look into this problem as soon as you are able. I don't know what to do anymore, and it's very important to me that the code works. Thank you for your time.
I hope to get an answer soon. This problem is really bothering my application. :(
Could you set up an extremely simple public test project I could clone? That would help diagnose the issue.
When creating a simple test application, I came to the decision that there is an error somewhere in my code. (something is blocking the Token) So I created the whole project again and it works great now. I apologize for my mistake and thank you for your support.
Please if you can help me why I always get this error the first time I call a function, the second time I run it then it works.
FileMaker Version: 18 Php Version : 7.4
This is a mistake:
{"messages":[{"message":"Request validation failed: Parameter (Authorization) is required","code":"10"}],"response":{}}
Thanks a lot for the reply.