Hexagon Geospatial
MENU

ERDAS APOLLO & ECW/JP2

Wondering how others have configured their ERDAS APOLLO server or what data they are crawling? The ERDAS APOLLO Discussion board is a place to find information, share ideas and more. Join the community, connect, contribute and share.
Showing results for 
Search instead for 
Do you mean 
Reply
Occasional Contributor
Posts: 9
Registered: ‎04-30-2019

403 error on patch request, 405 error on post request (Apollo REST.API)

[ Edited ]

Dear community, 

 

I come across some issues when I'm trying to use a POST or PATCH request on my data using the REST API.
The POST request (see screenshot) returns a 405 error. The payload is given and correct, yet the server doesn't seem to allow this action to be performed. Something similar could be said when I'm trying the same operation using a PATCH (403). My guess for the PATCH is that it refuses due to patch not being included in the Access-Control-Allow-Methods of the response headers. 

 

GET methods are working correctly, so I wonder where the problem is located. I have added my script for the POST method below, maybe there is a problem in there (Note: working with credentials give the same result).

 

My question is whether this is a backend server issue, or whether my script is missing something. We've had a backend issue before, yet I (as a intern) do not have access to the backend. The previous problem was discussed by my colleague in this post: 

https://community.hexagongeospatial.com/t5/ERDAS-APOLLO-ECW-JP2/Erdas-Apollo-REST-API-returns-403-er...

 

 

Script:

postEdit(context) {
Axios({
method: "post",
url: `http://orions/erdas-apollo/content/catalog/items/${
context.state.activeDataset.id
}`,
auth: {
username: "xxxx",
password: "xxxx"
},
headers: {
"Content-Type": "application/json",
Accept: "*/*"
},
data: {
title: this.state.activeDataset.title
}
})
.then(response => {
context.commit("editedDataset", response.data.results);
console.log(activeDataset);
})
.catch(error => {
this.fetchError = error;
console.log("No changes found", error);
});
}

 

Thanks in advance,

 

Reinier

Technical Evangelist
Posts: 1,118
Registered: ‎09-11-2015

Re: 403 error on patch request, 405 error on post request (Apollo REST.API)

Hi Reinier,

 

Can you "play" the actual POST request using e.g. Postman, Fiddler, or similar tools?

 

When looking at the code - at least, there are wrong apostrophes in the url parameter - are you sure they're correct in your original code? (`` instead of ' ')

 

Also, it seems to me like you're trying to call POST http://orions/erdas-apollo/content/catalog/items/${context.state.activeDataset.id}

But there's no such method allowed in the REST API, I can see only DELETE, GET and PATCH...

 

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Occasional Contributor
Posts: 9
Registered: ‎04-30-2019

Re: 403 error on patch request, 405 error on post request (Apollo REST.API)

[ Edited ]

Hello Jan, 

 

First of all thanks for replying to me.

 

Before I wanted to answer you, I wanted to check a few things including the topics you mentioned as potential problems.

 

  • I've tried the POST and PATCH in Postman. The patch works and updates any value in the catalogue as desired. The POST request indeed does not work. It returns an errorMessage saying "POST method not allowed if URL contains item ID" and 
    "The server encountered an unexpected condition which prevented it from fulfilling the request"
  • I know the code looks a bit strange using `` instead of ' ' but this actually functions well. Due to the use of Vue.js and a Vuex store, I can only include the state of the data if `` is used. I've used this before in requests to the API. 
  • Regarding the POST requests. I've attached a screenshot of the API console with the POST request that I was trying to use. It could be that I've tried to use it in a wrong way. 

Thanks for your help so far. 

 

With regards, 

 

Reinier de Graaf

Technical Evangelist
Posts: 1,118
Registered: ‎09-11-2015

Re: 403 error on patch request, 405 error on post request (Apollo REST.API)

Hi Reinier,

Do you supply the "propertyName" value? It is required for the POST call you mentioned.

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Occasional Contributor
Posts: 9
Registered: ‎04-30-2019

Re: 403 error on patch request, 405 error on post request (Apollo REST.API)

In the API console, I can not get anything to work using any propertyName. This means I also can not get a functioning request URL to use in my script. 

 

What I've tried to do in my script was to change a value of the 'active dataset' (a state in Vuex) and 'POST' the changes. It showed in the pictures (1st post) a payload containing the change. I'm not sure 100% sure if that's the right behaviour. 

Technical Evangelist
Posts: 1,118
Registered: ‎09-11-2015

Re: 403 error on patch request, 405 error on post request (Apollo REST.API)

I've just found out that the POST /content/catalog/items/{ID}/{propertyName} only apply to the following catalog item details:

"properties": {
   "apollo.connector": "com.erdas.apollo.hedm.connector.ImageryConnector"

}

 

Which isn't probably what you're looking for.

 

If you want to change standard data set properties, rather use PATCH /content/catalog/items/{ID} with proper payload, e.g.:

PATCH /content/catalog/items/{ID}

payload:
{
  "title": "atl_tiles_4_1.ecw"
}
Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Occasional Contributor
Posts: 9
Registered: ‎04-30-2019

Re: 403 error on patch request, 405 error on post request (Apollo REST.API)

Hey Jan, 

 

That would explain why the POST request isn't generating anything in my script, Postman and the API console. I'll continue trying it with PATCH, which works in the API console and Postman.

 

My assumption that the PATCH request isn't working due to PATCH not being listed in the Access-Control-Allow-Method of the response header, also doesn't seem to be the case. This because it does work in Postman without it. 

 

Greetings, 

 

Reinier

 

 

Technical Evangelist
Posts: 1,118
Registered: ‎09-11-2015

Re: 403 error on patch request, 405 error on post request (Apollo REST.API)

Maybe it has something to do with this:

https://stackoverflow.com/questions/43206233/vue-js-patch-method-not-allowed

https://github.com/pagekit/vue-resource/issues/576

 

 

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Occasional Contributor
Posts: 9
Registered: ‎04-30-2019

Re: 403 error on patch request, 405 error on post request (Apollo REST.API)

[ Edited ]

Hello, 

 

A small update on the progress.

Patching finally works. I can change the values of some of my properties and patch them to the Apollo server. However I have one current issue remaining which is trying to change true values to false and vice versa.

 

I've used the API to do this: 

 

{
  "acquisitionInfo": {
  "dataAcquired": "true"
  }
}

Opening the Chrome console during the process of the API I get a correct 204 status code and see the following payload:

{acquisitionInfo: {dataAcquired: "true"}}
      acquisitionInfo: {dataAcquired: "true"}
            dataAcquired: "true"

When trying to do the same patch from my own made editor. I do the exact same thing, I do get the exact same payload, yet the response headers are not showing up. I also get the following CORS related error.

 

Access to XMLHttpRequest at 'http://orions/erdas-apollo/content/catalog/items/4028828a6ab522ff016ab5eb6e49007d' from origin 'http://localhost:8084' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
store.js:125

No changes found Error: Network Error
at createError (createError.js:16)
at XMLHttpRequest.handleError (xhr.js:69)

xhr.js:160 PATCH http://orions/erdas-apollo/content/catalog/items/4028828a6ab522ff016ab5eb6e49007d net::ERR_FAILED
dispatchXhrRequest @ xhr.js:160

The error is not new. Despite CORS issues, I was always able to patch my names and dates. The displayed error of no changes found is technically incorrect. The current problem however is that for boolean fields, the changes don't work at all. 

 

Is there any specific reason that this is only happening for properties with boolean values? (It also works in Postman)

 

With regards, 

 

Reinier,

Technical Evangelist
Posts: 1,118
Registered: ‎09-11-2015

Re: 403 error on patch request, 405 error on post request (Apollo REST.API)

Do you have CORS headers properly configured on the APOLLO server as it was discussed in the linked Community thread above?

 

Also, the boolan values shouldn't be double-quoted ("true" instead of true). It may be improperly understood by JSON parsers.

 

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.