1

i fill in the needed data: - accountId: 2465955 - webPropertyId: UA-2465955-20 - customDataSourceId: oI7aVdXXRJa_ZA5QNvLkVQ

Request:

POST https://www.googleapis.com/analytics/v3/management/accounts/2465955/webproperties/UA-2465955-20/customDataSources/oI7aVdXXRJa_ZA5QNvLkVQ/uploads?fields=customDataSourceId&key={YOUR_API_KEY}

i grant the user access to see and edit data in analytics. after this i get the error:

    400

- Hide headers -

cache-control:  private, max-age=0
content-encoding:  gzip
content-length:  160
content-type:  application/json; charset=UTF-8
date:  Wed, 05 Sep 2018 09:01:04 GMT
expires:  Wed, 05 Sep 2018 09:01:04 GMT
server:  GSE
vary:  Origin, X-Origin

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "badRequest",
    "message": "Upload request URL should start with https://www.googleapis.com/upload/analytics/..."
   }
  ],
  "code": 400,
  "message": "Upload request URL should start with https://www.googleapis.com/upload/analytics/..."
 }
}

i dont know how to send a propper request, hope somone can help me!

thx

Jan
  • 13
  • 4
  • Please edit your question and include your code we cant help you debug what we cant see. – Linda Lawton - DaImTo Sep 05 '18 at 09:44
  • done, i added the account data in to the form, but i think it wount help. – Jan Sep 05 '18 at 10:13
  • How exactly are you sending this HTTP Post? What are you using to fire it off what you have given me i just just the raw request. I need to see the code that you are running after submitting your form if thats what your using. – Linda Lawton - DaImTo Sep 05 '18 at 10:21
  • i use the api explorer ... https://developers.google.com/apis-explorer/#p/analytics/v3/analytics.management.uploads.uploadData?accountId=2465955&webPropertyId=UA-2465955-20&customDataSourceId=gx3hqqEjR7qBrcgrIDkToQ&_h=3& – Jan Sep 05 '18 at 10:25

1 Answers1

0

The Uploads: uploadData method is used to Upload data for a custom data source.

You can not use Google apis exploerer to upload files. It does not have that functionality it is only meant for testing.

You will need to code this yourself here is a nice example in java directly from the documentation

/*
 * Note: This code assumes you have an authorized Analytics service object.
 * See the Data Import Developer Guide for details.
 */


// This request uploads a file for the authorized user.
File file = new File("data.csv");
InputStreamContent mediaContent = new InputStreamContent("application/octet-stream",
    new FileInputStream(file));
mediaContent.setLength(file.length());
try {
  analytics.management().uploads().uploadData("123456",
      "UA-123456-1", "122333444455555", mediaContent).execute();
} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      + e.getDetails().getCode() + " : "
      + e.getDetails().getMessage());
}
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • i had, but it dont work so i wanted to test the api method with the api explorer. So when this methode dont work at all with the api explorer thx for the hint! – Jan Sep 05 '18 at 10:43
  • thx, i added the question with the code https://stackoverflow.com/questions/52183820/google-analytics-api-v3-analytics-management-uploads-uploaddata-insufficient-p – Jan Sep 05 '18 at 11:22