#1 2018-01-04 15:11:56

otaciliobalves
Member
Registered: 2017-10-13
Posts: 6

HttpSetHeader Error Using Variables

Dear David,

Perhaps I'm wrong or confusing how to use HttpSetHeader, but when I'm trying to assign a variable to HttpSetHeader I have the following error:

[+] Start of buttonSearchTAC Click event
[a] 000001 GetCookie "usersession" "[userSession]"
[a] 000002 SetVar "[apiKey]" "changed for security reasons" "String"
[a] 000003 If "[userSession]" "!=" "''"
[a] 000004 Console "Session Info [userSession]" "info" Session Info eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI4M2VkNzgyODI4NjYxYWEyMzI2OWI3YmMwYzlkOTk2YSIsImlzcyI6Imh0dHA6Ly8xNzIuMTYuMTc5LjE6ODA4MC9hcGkvdjIvdXNlci9zZXNzaW9uIiwiaWF0IjoxNTE1MDcwOTIwLCJleHAiOjE1MTUwNzQ1MjAsIm5iZiI6MTUxNTA3MDkyMCwianRpIjoiZlVrQWw5ZzZERHRBdVFqeCIsInVzZXJfaWQiOjIsImZvcmV2ZXIiOmZhbHNlfQ.lCa9fI976tBVxRJVvdQSkYapN-9ZDLDOUF2Ajn9l7BM
[a] 000005 HttpSetHeader "loadTCR" "Accept" "application/json"
[a] 000006 HttpSetHeader "loadTCR" "X-Dreamfactory-Session-Token" "[userSession]"
[e] Error: "'Dreamfactory' is undefined" - Line: 307 - Char: 13 - Code: 0 - Url: [url]http://127.0.0.1:9999/app/scripts/app.js[/url]

As you can see in the console the variable [userSession] is defined and had a value, but when I assign to HttpSetHeader the following error comes.

Here is part of the code used in the application where the error appears:

GetCookie "usersession" "[userSession]"
SetVar "[apiKey]" "changed for security purposes" "String"
If "[userSession]" "!=" "\x27\x27"
   Console "Session Info [userSession]" "info"
   HttpSetHeader "loadTCR" "Accept" "application/json"
   HttpSetHeader "loadTCR" "X-Dreamfactory-Session-Token" "[userSession]"
   HttpSetUrl "loadTCR" "[url]http://172.16.179.1:8080/api/v2/imeidb/_table/tcrplus?&include_count=true[/url]"
   BlockApp
   HttpExecute "loadTCR"
Else
   Alert "Your session has been expired" "error"
   ShowView "Login"
EndIf

I appreciate any assistance you can give me.

Best Regards,
Otacilio Alves

Offline

#2 2018-01-04 17:04:01

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,715
Website

Re: HttpSetHeader Error Using Variables

Hello Otacilio,

Maybe this can't help, we must start with some point! The error in the console is "Error: "'Dreamfactory' is undefined"", and, I can't see the relation with this error nor identifier with the "userSession" variable.

Maybe the existing error causes in the app a bad behaviour or something like that?

In other words, please, take a look at what the refered error means. "Dreamfactory" is an app variable? Why is undefined?

Offline

#3 2018-01-04 19:37:24

otaciliobalves
Member
Registered: 2017-10-13
Posts: 6

Re: HttpSetHeader Error Using Variables

Hello David,

Thanks for your reply. I will go to make a double check and get back to you.

Offline

#4 2018-01-04 19:55:55

otaciliobalves
Member
Registered: 2017-10-13
Posts: 6

Re: HttpSetHeader Error Using Variables

Hi David,

I double checked and still the same error, even if I set the variable with SetVar and try assign in HttpSetHeader is still giving errors. Look the code below:

SetVar "[apiKey]" "27fb846d3a9442016d24883e8942210b306bd89d09ef992a3bcd50c7d9af6327" "String"
//GetOption "userSession" "[sessionId]"
If "[sessionId]" "!=" "''"
   HttpSetHeader "loadTCR" "Accept" "application/json"
   HttpSetHeader "loadTCR" "X-Dreamfactory-Api-Key" "[apiKey]"
   //HttpSetHeader "loadTCR" "X-Dreamfactory-Session-Token" "[sessionId]"
   //HttpSetUrl "loadTCR" "http://172.16.179.1:8080/api/v2/imeidb/_table/tcrplus?api_key=[apiKey]&session_token=[sessionId]&include_count=true"
   //HttpSetUrl "loadTCR" "[url]http://172.16.179.1:8080/api/v2/imeidb/_table/tcrplus?&include_count=true[/url]"
   //BlockApp
   //HttpExecute "loadTCR"
Else
   Alert "Your session has been expired" "error"
   ShowView "Login"
EndIf

Now check the error below:

[+] Start of totalRecords Click event
[a] 000001 SetVar "[apiKey]" "27fb846d3a9442016d24883e8942210b306bd89d09ef992a3bcd50c7d9af6327" "String"
[a] 000002 If "[sessionId]" "!=" "''"
[a] 000003 HttpSetHeader "loadTCR" "Accept" "application/json"
[a] 000004 HttpSetHeader "loadTCR" "X-Dreamfactory-Api-Key" "[apiKey]"
[e] Error: "'Dreamfactory' is undefined" - Line: 307 - Char: 13 - Code: 0 - Url: [url]http://127.0.0.1:9999/app/scripts/app.js[/url]

See... even if I set the variable manually with SetVar the error still exists. It's like HttpSetHeader is compiling wrong in some way.

If you can help me I will appreciate.

Best Regards,
Otacilio Alves

Offline

#5 2018-01-04 22:21:30

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,715
Website

Re: HttpSetHeader Error Using Variables

Hello Octacilio,

My apologies. Certainly I can't understand the problem at the first time, but, you explain it very well and I can in fact test it to view what really happen. Actually, you are completely right and found an error when App Builder translate the HttpSetHeader action, which occur when the value to be established come from an app's variable. The error is fixed now, so please, upgrade your AB copy Octacilio.

My apologies again, because, in fact, if I test the code before, I can suggest you the below possible aproach, until I can prepare the appropriate bug fix and then upgrade App Builder:

StartJS
  $rootScope.loadTCR.Request.headers["X-Dreamfactory-Api-Key"] = $rootScope.userSession;
EndJS

The above code is a possible translation of the HttpSetHeader action (in fact what you need), then we can use the "StartJS" and "EndJS" actions to directly use that Javascript code. Anyway this is not required now, since AB is now fixed and you can upgrade your copy now.

Please, let me know if you have any further questions!

Offline

#6 2018-01-06 15:03:03

otaciliobalves
Member
Registered: 2017-10-13
Posts: 6

Re: HttpSetHeader Error Using Variables

Hello David.

Thanks for the fix since I was breaking my head with that :-). Therefore I will download the new updated version and test.

Once again David thanks for your prompt attention and solution.

Best Regards,
Otacilio Alves

Offline

#7 2018-01-06 15:04:13

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,715
Website

Re: HttpSetHeader Error Using Variables

Hello to all,

otaciliobalves wrote:

Hello David.

Thanks for the fix since I was breaking my head with that :-). Therefore I will download the new updated version and test.

Once again David thanks for your prompt attention and solution.

Best Regards,
Otacilio Alves

You're welcome Otacilio! Please, sorry again for the inconveniences.

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.