Hero Banner

Secure Application Model

Learn and ask questions on how to implement secure application model

Reply
R_MILL_BEC
Visitor 1

call to Partner API returning 500 response

Hello there, 

I'm writing an application for a Microsoft Partner Storefront. I am able to generate an access token, but using it to get all the customers is returning a 500 (internal server error). I am able to run this same code in Postman and it returns a 200. 

const getAllCustomers = async (accessToken=> {
  ACCESS_TOKEN = accessToken;
  try {
    const response = await fetch(CUSTOMER_PORTgetCustomerOptions)
    console.log("response"response)
    const data = response.json()
    data.then(json => console.log("This is the response from getAllCustomers()"json))
  } catch(err){
    console.log(err)
  }
}

let headers = new Headers();
headers.append("Authorization"`Bearer ${ACCESS_TOKEN}`);
headers.append("Accept""application/json");
headers.append("MS-RequestId"MS_REQUEST_ID);
headers.append("MS-CorrelationId"MS_CORRELATION_ID);

let getCustomerOptions = {
  method: 'GET',
  headers: headers,
  redirect: 'follow'
};

and this is what is logged to the console:

response Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: PassThrough {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: true,
[Symbol(kCapture)]: false,
[Symbol(kTransformState)]: [Object]
},
disturbed: false,
error: null
},
[Symbol(Response internals)]: {
url: 'https://api.partnercenter.microsoft.com/v1/customers?',
status: 500,
statusText: 'Internal Server Error',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
}
This is the response from getAllCustomers() {
statusCode: 500,
message: 'Internal server error',
activityId: 'e8e25573-ad58-4db5-9106-889af4591825'
0 REPLIES 0