Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET data (as carepartner) (EU) results in Error: Request failed with status code 400 #39

Open
sirKitKat opened this issue May 23, 2023 · 18 comments

Comments

@sirKitKat
Copy link

sirKitKat commented May 23, 2023

Nothing changed on my side but I suddenly started getting this error (Around 16:00 CEST)

The script is fetching the data from the following URL:
https://clcloud.minimed.eu/connect/carepartner/v6/display/message

Anyone an idea how to resolve this issue?

(Country: Belgium)

@sirKitKat
Copy link
Author

sirKitKat commented May 23, 2023

The URL is retrieved from medtronic (see carelink.js)
The data send to medtronic is the username and the userrole with the following piece of code (see carelink.js):

  logger.log('GET data (as carepartner) ' + dataRetrievalUrl);
  var body = {
    username: options.username,
    role: "carepartner"
  };
  return await axiosInstance.post(dataRetrievalUrl,body,{
    
  });

Could it be that the body that is send to medtronic needs other information? And is there a way I can find that information?

For completness: the log information:

2023-05-23T19:50:26.054Z [Arguments] {
  '0': 'GET data (as carepartner) https://clcloud.minimed.eu/connect/carepartner/v6/display/message'
}
MiniMed Connect error: Error: Request failed with status code 400
stack: Error: Request failed with status code 400
    at createError (/opt/app/node_modules/minimed-connect-to-nightscout/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/opt/app/node_modules/minimed-connect-to-nightscout/node_modules/axios/lib/core/settle.js:17:12)
    at /opt/app/node_modules/minimed-connect-to-nightscout/node_modules/axios-cookiejar-support/lib/interceptors/response.js:79:25
    at new Promise (<anonymous>)
    at responseInterceptor (/opt/app/node_modules/minimed-connect-to-nightscout/node_modules/axios-cookiejar-support/lib/interceptors/response.js:78:9)
    at /opt/app/node_modules/minimed-connect-to-nightscout/node_modules/axios-cookiejar-support/lib/index.js:130:67
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async getConnectData (/opt/app/node_modules/minimed-connect-to-nightscout/carelink.js:254:24)
    at async Object.fetch (/opt/app/node_modules/minimed-connect-to-nightscout/carelink.js:310:29)

@mstietencron
Copy link

mstietencron commented May 23, 2023

same here. since today 1600 CEST I have the same error. Haven't found any solution yet. :(

iPhone Apps work fine.

@colebrusco
Copy link

same thing here 😒

@sirKitKat
Copy link
Author

In the URL, I see a mention of v6 what probably stands for Version 6. Maybe, if someone still knows the url for the previous version, we can fetch the data through the old url?

@mstietencron
Copy link

mstietencron commented May 23, 2023

Great idea

In the URL, I see a mention of v6 what probably stands for Version 6. Maybe, if someone still knows the url for the previous version, we can fetch the data through the old url?

A simple swap for "v5" gives results!

@mstietencron
Copy link

mstietencron commented May 23, 2023

🥳 this hotfix did it. I added a new line 248 to carelink.js updating the function getConnectData() as follows:

` async function getConnectData() {
var currentRole=await getCurrentRole();

  if(currentRole === "CARE_PARTNER_OUS" || currentRole === "CARE_PARTNER") {
      var dataRetrievalUrl = null;
      var resp = (await axiosInstance.get(CARELINK_COUNTRY_SETTINGS_URL));
      if (resp && resp.data && resp.data.blePereodicDataEndpoint) {
        dataRetrievalUrl = resp.data.blePereodicDataEndpoint;
      }
      dataRetrievalUrl = 'https://clcloud.minimed.eu/connect/carepartner/v5/display/message' // HOTFIX
      if(dataRetrievalUrl) {
            logger.log('GET data (as carepartner) ' + dataRetrievalUrl);
            var body = {
                username: options.username,
                role: "carepartner"
            };
            return await axiosInstance.post(dataRetrievalUrl,body,{

            });
      } else {
        throw new Error('Unable to retrieve data retrieval url for carepartner account');
      }
  } else {
    var url = await carelinkJsonUrlNow();
    logger.log('GET data ' + url);
    return await axiosInstance.get(url);
  }
}`

With this change it works again for me! Thanks @sirKitKat for the simple yet genius idea!

@sirKitKat
Copy link
Author

Nice, this is, however, a temporary fix. It will work until Medtronic deprecates version 5. Nevertheless, it is working right now. :)

@artempartos
Copy link

confirm V5 also working for me

@sirKitKat
Copy link
Author

Today, the care app received the following update:
Screenshot_20230524-092942
So this explains the why, now someone needs to figure out how we can adres the version 6 of the API

@bewest
Copy link
Member

bewest commented May 28, 2023

I'm interested in collecting credentials and helping to document/implement this.
I can patch current repo to use v5, are there other changes needed in the flow? Does this behavior only affect logging in as carepartner account?

@bewest
Copy link
Member

bewest commented May 29, 2023

I have a pull request for this. #37

Working on a release, ran into a snag with npm, but it would be really helpful for people to test it more completely while that gets resolved.

@bewest
Copy link
Member

bewest commented May 30, 2023

I released 1.5.4, https://www.npmjs.com/package/minimed-connect-to-nightscout.
It's not super clear to me if this works completely or if it fetches data correctly, or if the patientId is also needed. I see a fair bit of activity in xdrip for this. If someone would be willing to share their credentials with me, I'd like to get this fixed up a bit.

@nfontan
Copy link

nfontan commented May 30, 2023

I released 1.5.4, https://www.npmjs.com/package/minimed-connect-to-nightscout. It's not super clear to me if this works completely or if it fetches data correctly, or if the patientId is also needed. I see a fair bit of activity in xdrip for this. If someone would be willing to share their credentials with me, I'd like to get this fixed up a bit.

Hi Ben, I sent you a message on gitter

@stijnbrouwers
Copy link
Contributor

Actually, it can be fixed without reverting back to v5.

To do this, in "carelink.js", the "getConnectData"-function should be changed where we build the body for the case
currentRole === "CARE_PARTNER_OUS" || currentRole === "CARE_PARTNER

var body = {
  username: options.username,
  role: "carepartner"
}

should become

var body = {
  username: options.username,
  role: "carepartner",
  patientId: "xxx"
}

where patientId should be the patient's username that you want to monitor.

So I guess we need to introduce a new environment variable that contains that information and edit the body.
This way we don't have to implement a workaround, but actually fix the root of the issue.
You guys agree that the best way to introduce the patientId would be to use an environment variable?

(Credits to @sedy89: NightscoutFoundation/xDrip#2823 (comment))

@stijnbrouwers
Copy link
Contributor

I Create a quick PR with the changes that would be required: #40

@bewest
Copy link
Member

bewest commented Jun 7, 2023

There patches implementing M2M functionality in nightscout-connect, dev: nightscout/nightscout-connect#4. I'm thinking of deprecating this module in favor of the unifed nightscout-connect. We could leave the "v5 fix" in here, and then target all new M2M featureset in the new module.

Are there still users depending on the older feature set? When is the ble endpoint used to poll for data instead of the M2M endpoint? Is the whole world m2m enabled now?

@stijnbrouwers
Copy link
Contributor

@bewest the old PR is removed and a new one created #41

@stijnbrouwers
Copy link
Contributor

stijnbrouwers commented Jul 2, 2023

@bewest the PR is merged in master now, but the hotfix is still in place in carelink.js

// HOTFIX
// https://github.com/nightscout/minimed-connect-to-nightscout/issues/39
dataRetrievalUrl = dataRetrievalUrl.replace('/carepartner/v6/display/message', '/carepartner/v5/display/message');

The fix of PR #41 works only with the latest endpoint (v6) not with V5...

Removing the aforementioned lines should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants