Trouble posting a JSON array pass to URL for authentication

Hey Bubblers!

I am trying to integrate the Weepay payment system into my application. I created a server-side action for this. But I have problems during the authorization phase.

They split the JSON parameters in half. They give the auth part “PATH”. I need to send JSON array in URL for authorization and I use URL Encode JSON for this.

function(properties, context) {

var options = {
    "async": true,
    "crossDomain": true,
    "url": "https://api.weepay.co/Payment/PaymentCreate?%22Auth%22%3A%7B%22bayiId%22%3A%2218890%22%2C%22apiKey%22%3A%22XXXXXXXXX%22%22%2C%22secretKey%22%3A%22XXXXXXXXXXXXXXXX%22%7D",
    "method": "POST",
    "headers": {
        "Content-Type": "application/json"
	}
};

  var response = context.request(options);
    
    
 
 return{
	status: response.body
 }
}

As a result, I get the error “Blank information cannot be sent”. But I’m sure there are no spaces.
When I do this POST from API Connector, I get a 400 error.

Does anyone have any idea how I can fix this error or suggest another way?

API Documentation

Could you please take a look?
@NigelG @keith

You are posting data in url but the API expect a json payload. Add a body with a JSON.

Another question, why don’t you use the API Connector?

1 Like

Thank you! @Jici

I tried to send the JSON information I encoded for Auth in the API Connector but I got the same error.

As another solution, I tried sending the whole in the body but still got the same error. So I wanted to try my luck on the plugin side as well.

In the document, it separated the Auth stage as “path” from “body”. I did not understand how I could do this.

I will be grateful if you could help me.

Thank you again!

1 Like

You need to also add header for content type jsonin api connector too

2 Likes

Greetings again! @Jici

As you can see in the first image in my previous reply, I defined the “application/json” value for the “Content-Type” key in the “header” section. Is that what you mean? When I searched the internet, I couldn’t find anything else. Can you be a little more revealing?

1 Like

Hey! @Jici
The document of the system I tried to integrate was incorrect. What we did with the API connector is correct.
Thank you so much for trying to help, I’m grateful!

Best regards

2 Likes