Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
webtronix
Contributor III
Contributor III

NPrint API POST error - HTTP protocol error 405 (Method Not Allowed):

Hi folks

I have a very bizarre error here.

I've implemented an API code in Qlik that invokes an NPrint task.

This works perfectly, or has done until last week, where it's failed with the following error below.

The bizarre bit is that I have several of these Apps with the API built in to run and invoke the NPrint task, and some of them work whilst others that did work perfectly have stopped.

We've not done any changes to the App, the API App or even the NPrint related apps.

This happened a few months back and we simply re-built everything from scratch and it worked, identical code between both working and failed. The only difference would have been the Qlik sense ID attached to the API app running this.

Has anyone had similar issues and any idea what the cause of this could be?

 

I've attached both working and failed logs and also the API code used.

 

---

RestConnectionStatusTable << RestConnectorMasterTable
Lines fetched: 1
connection_data << RestConnectionStatusTable
Lines fetched: 1
'Polling until Cache Status of the Conn : CCP PNS CON FTTP WSS becomes "Generated"'

Connected
RestNPTasksMasterTable << RestConnectorMasterTable
Lines fetched: 51
task_items << RestNPTasksMasterTable
Lines fetched: 0
'For the ANP App : CCP PNS APP FTTP WSS'

'Now trigerring task : '

'Task ID of : '

'The POST API is : https://servername:61001/api/v1/tasks//executions'
Connected
RestNPTaskTriggerTable << RestConnectorMasterTable
The following error occurred:
HTTP protocol error 405 (Method Not Allowed):

{"message":"The requested resource does not support http method 'POST'."}
The error occurred here:
RestNPTaskTriggerTable:
SQL SELECT "__KEY_data" FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "https://servername:61001/api/v1/tasks//executions", HTTPHEADER "cookie" "NPWEBCONSOLE_SESSION=18dfed88429f148f8e9466f365d7a46ec0e55b25-%00userlogin%3A2024-12-02T12%3A39%3A43.3729796Z%00%00NPWEBCONSOLE_XSRF-TOKEN%3AOlhc2Wz9S%2FEomVLgjD2D06k1Y4A%2BRiAyiN9VFAMmjV0%3D%00%00_TS%3Asession%00%00userid%3Afce33700c7314de68ed79486071525ec%00;")
Data has not been loaded. Please correct the error and try loading again.

 

---

 

 

 

Labels (1)
  • HTTP

10 Replies
FabioSanchesRibeiro

Hi @webtronix,

I'm not entirely sure, as I couldn't identify each iteration of the loop.

However, it seems that in this part of the code:

'Task ID of : '

'The POST API is : https://servername:61001/api/v1/tasks//executions'

The Task ID was not populated in the iteration that caused the error.

It’s possible that the loop is executing one extra step, which might be triggering an error during execution.

webtronix
Contributor III
Contributor III
Author

Thanks for replying. This is where I'm at a loss as the main API code (previously attached) is something that was given to me, possibly from this forum and if I run the API code in a fresh app, it will work, but somehow it fails in an existing, previously working app.

I have a feeling that there is something else underlying in the Qlik repository (cache maybe) that is causing this to fail randomly.

The thing is that once it fails, it will never work and I have to re-build, (copy paste) the whole code into a new app and then if I run it, it will work, (how !?!)

Maybe I need to get the Qlik Engineers onto this

FabioSanchesRibeiro

It's necessary to understand which data is being collected in each application. Something might have happened over the application's lifecycle, such as a failure or some other issue, which could be generating an event that the script, as it is, cannot interpret and handle properly.

I would suggest identifying the app where the script doesn't run and analyzing the data being generated or not generated that causes this failure. From there, you can adjust the script to either fix or bypass this anomalous condition.

webtronix
Contributor III
Contributor III
Author

But this is where it becomes interesting as the same code copied into another app will work.

This is the lineage

Source data imported from an Oracle environment into a QVD

There is a main app that has the tables and visuals from what the N Print app is built on, via N Print App, Connections, Tasks etc, which work and send out the e-mails, which is fine.

Then I have a separate app, which simply has the API code. This API code simply invokes and 'handshakes' to the N Print server.

The issue here is that I get this 'protocol error 405' and then this API app is rendered useless.

Now if I duplicate the app from the published stream, copy all the sections into a band new app and then load the data, it works!

So there doesn't seem to be anything wrong with the code or the N Print app or connections.

If I go back to the 'faulty' app with the API, it fails (which has the same entire code!)

 

I'm hoping my spiel makes sense 🙂

(.ps. thanks for engaging here )

 

--- code below bespoke for each N Print App

// Save the NP App Name and supply the same app name that you have created
let vAppName = 'CCP PNS APP FTTP Weekly Summary';

// Prepolulate this with the number connections the NP App has
let vNoOfConns = 1;

// Prepolulate this with the number tasks the NP App has
let vNoOfTasks = 1;

 

//rest of the API code below (very long - see attached file )

//end

---- code above

 

 

FabioSanchesRibeiro

The 405 error is occurring because you are calling the NPrinting API using the POST method on the execution endpoint.

This endpoint requires you to provide the APP ID, and that is not happening in the last iteration of the loop.

This issue is not related to the NPrinting app or the Qlik Sense app where you are sourcing the data from.

You are invoking the NPrinting API and passing parameters to it. At this stage, other elements can be ruled out.

webtronix
Contributor III
Contributor III
Author

But then why is this working on another app with the same API code ?

FabioSanchesRibeiro

That's why I mentioned earlier the importance of understanding the data being collected during the script execution.

This script is gathering all the connections and tasks related to each app you provide.

Each app has its own chain of connections and tasks, and based on the information we have so far, for certain apps, the final loop (considering "final" as the part where the script fails) does not pass the necessary parameter for the final call. This causes the script to lack the parameter required for the API call being made.

In the last step of the script, it generates a table with all the tasks of the app. It’s crucial to analyze this table to understand why the script is attempting to make a POST call without passing the Task ID!

webtronix
Contributor III
Contributor III
Author

Thanks for the details,

So this has been my RCA so far, but not been able to resolve, but managed a workaround.

I have many API apps built. All of them worked, but some have started to fail as mentioned earlier and that's without any changes to the Qlik App / API app or anything related to NPrint.

Previously, duplicating the app worked, but even this now fails.

In My NPrint, I labelled each stage as 'APP' for App / 'CON' for Connection / 'TSK for Task, so in NPrint, Under Task Executions, I could see what the API was doing and at what stage this was being polled at, at least from a GUI perspective.

The App works as can be seen in the load progress window.  As it polls, I can see it's trying to generate the cache via the 'CONN' connection as this can be seen in the 'Task Executions' in NPrint.

When it failed, the 'TSK' could not be seen.

Now for the workaround.

I created a new task, duplicating the original one and then disabling the original one and then re-run the API

It worked !!

 

So the question here is, why has it failed in a working environment. All I did was duplicated the task, like-for-like and it worked.

 

Strangely though, If I trigger the original task via NPrint, it works.

 

So is something happening back end of Qlik repositories that is corrupting a connection via API somewhere?

webtronix
Contributor III
Contributor III
Author

Just wanted to add that after I disabled the task that was linked within NPrint and then recreated a new task with the same name, as per usual, I have a schedule that runs daily, this kicked off the API this morning and I received the NPrint notification.

So the cause is primarily something to do with the NPrint task, even though it does not cause an issue when manually invoked in NPrint, it does when invoked by Qlik Sense via the API call, but only to a particular task.

I have another API which has worked flawlessly without any issues.