Learn business growth with Google Analytics 4 Forums Google Analytics 4 Incorrect URL Path for GA4 Data API 404 Error

  • Incorrect URL Path for GA4 Data API 404 Error

    Posted by Alex on 26 August 2022 at 8:16 pm

    I’m having a problem accessing GA4 data for some webpages. My sites are in Coldfusion so I don’t use a client library. According to the latest Data API
    Google Analytics Data API v1 migration guide, there’s this link I can use without a client library.

    https://analyticsdata.googleapis.com/v1beta.

    But when I try to POST JSON here,

    https://analyticsdata.googleapis.com/v1beta/properties/XXXXXXXX:runReport
    

    I get a 404 error. Has the link been changed?

    I used the OAuth access token in the header. I’m pretty sure that if there was an issue with auth, I’d get a “not authorized” error instead. But all that’s coming up is:

    “The requested URL /v1beta/properties/XXXXXXXX:runReport was not found on this server. That’s all we know.” And a 404 status code

    Am I missing something super obvious here?

    Alexander replied 11 months, 1 week ago 3 Members · 2 Replies
  • 2 Replies
  • Jayden

    Member
    24 September 2022 at 9:08 pm

    I see you’re having some problems with your GA4 data for a specific page and you’re getting a 404 error. It seems like there’s a chance you might have missed a section in the migration guide about how to use the Data API without a client library. It’s really important to follow that properly to avoid errors.

    Looking at your code, it seems like the conversion to GA4 might not be complete. For instance, you’re still using a UA metric ga:medium and there’s also a viewId in your code, which shouldn’t be there.

    So, you might want to revisit the data API basics. The format for your POST request should look something like this:

    `
    POST https://analyticsdata.googleapis.com/v1beta/properties/GA4_PROPERTY_ID:runReport
    Authorization: Bearer [YOUR_ACCESS_TOKEN]
    Accept: application/json
    Content-Type: application/json
    {
    “dateRanges”: [{ “startDate”: “2020-09-01”, “endDate”: “2020-09-15” }],
    “dimensions”: [{ “name”: “country” }],
    “metrics”: [{ “name”: “activeUsers” }]
    }
    `
    Please double-check these points and hopefully, that should solve your problem!

  • Alexander

    Member
    16 February 2023 at 7:24 am

    It seems like you might be using the wrong request type. The response you’re receiving indicates that the server couldn’t find the requested URL, which often happens when a URL that requires a POST request is accessed using a GET request. Therefore, please make sure you’re using a POST request to access that URL. If you use the wrong request type, the server will be unable to process your request properly, which can lead to errors like the one you’re experiencing.

Log in to reply.