Skip to content

.Send method does not omit empty values at is should #8

Open
@EstoyAburrido

Description

@EstoyAburrido

Hi. I'm trying to send a request as follows:

	rawResp, err := st.Send(&cpreq.StopTransaction{
		TransactionId:	ocppVars.TransactionId[id],
		MeterStop:		int(ocppVars.Connectors[id].Consumed),
		Timestamp:		time.Now(),
		Reason:			"Remote",
	})

And StopTransaction struct has 'omitempty' json parameters on each non-required field but when I send the request the server(which is not based on the same library) gets this:

"StopTransaction",{"idTag":"","meterStop":13740,"reason":"Remote","timestamp":"2020-12-03T20:41:33+03:00","transactionData":null,"transactionId":1}

It complains about transactionData and replying with the following error message:

Error: Invalid value "null" for field transactionData

As you can see all the other optional fields are also included in the query.

Any idea how do I send the request omitting optional values ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions