Skip to main content
Announcements
UPGRADE ADVISORY for Qlik Replicate 2024.5: Read More
cancel
Showing results for 
Search instead for 
Did you mean: 
RajneeshSharma
Contributor III
Contributor III

Enterprise manager REST API PUT call not working

HI

 

I am trying to call below API 

curl -i -k -v -X PUT --header "EnterpriseManager.APISessionID: wCo0_KvjEUFROvfHF5KGrw" --header "Content-Length: 242" https://computer.network.net/attunityenterprisemanager/api/v1/servers/myrepsrv1/def -T "C:\myrepsrv1.json"

 

I have put my APISessionID  and url  and its connecting fine. At the end of log message, it says 

> Content-Type: application/json
> Content-Length: 242
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
HTTP/1.1 100 Continue

* We are completely uploaded and fine

 

and then gets stuck.

Any idea, whats going on. I am able to run REST API GET commands. I see below line in enterprise manager log when GET command is successful

25 2024-03-29 02:21:48 [Manager ] [INFO ] Executing public api AemGetServer.

Labels (1)
1 Solution

Accepted Solutions
RajneeshSharma
Contributor III
Contributor III
Author

Issue resolved. Content-Length header should have the exact value as the json file length. Even if you give more, it doesn't work. Better to not use Content-Length at all and let the API figure it out itself.

View solution in original post

8 Replies
RajneeshSharma
Contributor III
Contributor III
Author

another question, what does -T parameter do.  How can I update a setting without using .json file, just by putting it in curl command line

john_wang
Support
Support

Hello @RajneeshSharma ,

The HTTP 100 Continue code indicates that everything is OK and that the client should continue with the request or ignore it. And I noticed some solution is Try adding an empty line (CRLF) after the 100 Continue line. Together,I do not see an issue in QEM.

-T parameter is used to upload the json file. You may import the json file directly by call:

curl -i -k -X POST --header "EnterpriseManager.APISessionID: wCo0_KvjEUFROvfHF5KGrw" --header "Content-Length: 242" --header "Content-Type: application/json" "https://computer.network.net/attunityenterprisemanager/api/v1/servers/myrepsrv1?action=import" -T " C:\myrepsrv1.json"

Detailed information in UG.

Hope this helps.

John.

 

Help users find answers! Do not forget to mark a solution that worked for you! If already marked, give it a thumbs up!
Heinvandenheuvel
Specialist III
Specialist III

I see that "Content-Length" is set to 242, which matches the example in AEM API Guide, but does it happen to match the contents of your provided JSON file as well??  It should, shouldn't it?

Maybe you told it that 242 bytes were coming, it saw fewer and not says - 100 -  please provide more bytes.

Dunno really only used the .NET API  from Powershell.

Hein.

Shai_E
Support
Support

Hi @RajneeshSharma ,

 

Other then what was already mentioned here, which i think are good suggestions to start with here are a few more:

1. Match the same curl example exactally one to one that means the same flags as well, without adding any

 

2. Try the same request in postman, see if that works.

From there if it works you can export a curl command from there and that will most likely add what you are missing

 

3. Run it via curl again but turn on verbose logging for the QEM server and search in the log for the endpoint URL that should give you more details on what is going on behind the scenes.

4. Make sure you are giving the correct server name for the URL parameter

Finally, here is the API documentation for this endpoint:

PutServer | Qlik Enterprise Manager Help

RajneeshSharma
Contributor III
Contributor III
Author

Issue resolved. Content-Length header should have the exact value as the json file length. Even if you give more, it doesn't work. Better to not use Content-Length at all and let the API figure it out itself.

RajneeshSharma
Contributor III
Contributor III
Author

Hello @john_wang 

 

I tried below

curl -i -k -v -X POST --header "EnterpriseManager.APISessionID: PXGgboAmc9pjTUPyANj2gw" --header "Content-Type: application/json" https://xxxxxxxx/attunityenterprisemanager/api/v1/servers/xxxx?action=import -T c:\myrepsrv1.json

myrepsrv1.json

{"$type": "AemReplicateServer", "name": xxxx", "description": "test", "host": "test", "port": "3552", "username": "admin", "password": "{{}}", "verify_server_certificate": false, "monitored": true}

but it gives me below error

{"error_code":"DESERIALIZE_TO_TYPE","error_message":"Failed to deserialize json to type ReplicationDefinitionExport: Type specified in JSON 'Attunity.AemDataModel.AemReplicateServer, AemDataModel, Version=2022.11.0.860, Culture=neutral, PublicKeyToken=null' is not compatible with 'Attunity.Replicate.Globals.ReplicationDefinitionExport, RepuiGlobals, Version=2022.11.0.860, Culture=neutral, PublicKeyToken=null'. Path '$type', line 1, position 30.."}*

Looks like it didnt like  "AemReplicateServer"

Any idea?

Heinvandenheuvel
Specialist III
Specialist III

@john_wang  - Only after the second dedicated port, and the final reply where, I noticed that you accidently provided the wrong API for server definition. The one @RajneeshSharma provided in the initial post was correct, except for the length provided. 

Perhaps you can update you reply with warning or correction as you see fit?

Hein

 

john_wang
Support
Support

Hi @Heinvandenheuvel ,

Really appreciate you point it out.

Hi @RajneeshSharma ,

In my previous reply the answer is inaccurate - I suggested you try:

...attunityenterprisemanager/api/v1/servers/myrepsrv1?action=import" -T " C:\myrepsrv1.json"

But that's the equivalent of ImportAll (tasks, databases, serversettings), NOT a server name definition as the you wanted. As your final comment pointed out, the reason is "Content-Length header should have the exact value". I apologize for the inaccurate.

Best Regards,

John.

Help users find answers! Do not forget to mark a solution that worked for you! If already marked, give it a thumbs up!